0

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;
2
  • You have incorrect syntax. This will work: WHERE (city='chennai' OR city = 'madurai') AND DOB='december 8 1996' Commented Jul 4, 2019 at 15:12
  • or use where city IN ('chennai','madurai') AND DOB='december 8 1996'. Commented Jul 4, 2019 at 15:32

1 Answer 1

2

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.