Reputation: 19
display all rows where the hiredate is before april 1, 1981 and the employee name is from A to S
This is the code that I have done and it doesn't work. :( When I tried to put AND
between '%A
' and '%S'
it doesn't work either. :( When I deleted the '%S'
it worked but it will only retrieve the record with a name starting with letter A
. :(
Can you guys help? I really don't know what to do. :(
SELECT *
FROM tblEmployee
WHERE HIREDATE < '1981-04-1'
AND ENAME LIKE '%A' '%S'
Thanks. ^^
Upvotes: 0
Views: 65
Reputation: 54084
TRY
SELECT * FROM tblEmployee WHERE HIREDATE < '1981-04-1' AND ENAME REGEXP '^[a-s]+$'
Upvotes: 0
Reputation: 70369
Use
SELECT * FROM tblEmployee WHERE HIREDATE < '1981-04-01' AND SUBSTR ( ENAME, 1, 1 ) BETWEEN 'A' AND 'S'
Upvotes: 1
Reputation: 115660
You were close. I guess you want names starting from A, B, C, ... S (not ending in A-S). Right?
If yes, try this:
SELECT *
FROM tblEmployee
WHERE HIREDATE < '1981-04-01' --- notice the -01
AND ENAME >= 'A'
AND ENAME < 'T'
Upvotes: 1