SQL 帮助显示具有 2 个相同字母的姓名。现在报错
很抱歉问了这么多关于 SQL 的问题,但我正在做练习来帮助我复习测试。
我试图显示所有名字中有 2 个 L 且 depno = 30 或他们的 super 是“7782”的人的名字。我已经为其编写了一些代码,但它给出了错误。我为经理使用了列名称“SUPER”。
SELECT ENAME
FROM emp
WHERE ENAME LIKE 'L%', DEPTNO = 30;
OR SUPER = '7782';
再次非常感谢!
-Jay
找到了答案: 答案实际上应该是:
SELECT ENAME
FROM emp
WHERE ENAME LIKE '%L%L%' AND DEPTNO = 30
OR SUPER = '7782';
因为这里给出的其他代码给了我一个错误,因为第三行的末尾不应该有分号。
sorry to ask so many questions about SQL but I am doing exercises that help me revise for my test.
I am trying to display the names of all people who have 2 Ls in their name and are in depno = 30 or their super is "7782". I have written some code for it but its giving an error. I have used the Column name "SUPER" for the manager.
SELECT ENAME
FROM emp
WHERE ENAME LIKE 'L%', DEPTNO = 30;
OR SUPER = '7782';
Thanks alot again!
-Jay
Found the answer:
The answer should actually be:
SELECT ENAME
FROM emp
WHERE ENAME LIKE '%L%L%' AND DEPTNO = 30
OR SUPER = '7782';
because the other codes given here give me an error as the end of third line is not supposed to have a semicolon.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该可以做到:
请注意,LIKE '%L' 可能会阻止索引的使用。
This should do it:
Be aware that the LIKE '%L' might prevent the usage of an index.
<代码>选择*
从你的桌子上
其中名称如“%L%L%”
或 depno = 30
或超级 = 7782
Select *
from yourtable
where name like '%L%L%'
or depno = 30
or super = 7782