Jay
Jay

Reputation: 540

SQL assistance with displaying names who have 2 same letters. Gives error now

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.

Upvotes: 1

Views: 2380

Answers (2)

user596075
user596075

Reputation:

Select * from yourtable where name like '%L%L%' or depno = 30 or super = 7782

Upvotes: 2

Yves M.
Yves M.

Reputation: 3318

This should do it:

SELECT   ENAME 
FROM     emp 
WHERE    ENAME LIKE '%L%L%', DEPTNO = 30; 
OR       SUPER = '7782'; 

Be aware that the LIKE '%L' might prevent the usage of an index.

Upvotes: 3

Related Questions