Reputation: 195
I have one table called student.I want to select a student name who is living in chennai or madurai and born on december 8 1996.The table column name is (name,city,DOB). Sort the result by name. I have written like this and i got error "Invalid relational operator".
SELECT name
FROM student
WHERE city='chennai' OR 'madurai' AND DOB='december 8 1996'
ORDER BY name;
Upvotes: 0
Views: 115
Reputation: 94682
You have to mention the column in each where clause test.
Also if you are mixing AND and OR you need to apply some parenthasis to ensure they are applied correctly.
Also the date should be in yyyy-mm-dd
format Assuming that you have deined DOB
as a DATE type. And you should have if it is holding a date.
SELECT name
FROM student
WHERE (city='chennai' OR city='madurai' ) AND DOB='1996-12-08'
ORDER BY name;
Upvotes: 2