1

I am trying to select students within a MYSQL database where their dates of birth are in certain months (May, June or July) here is what I think the command is:

SELECT studentid, fName, lName, dob
WHERE MONTH(dob)='5'
FROM student;

Here is an example of a records: Example of records image

However I put this in the PHPmyadmin sql box and it returns an error:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE MONTH(dob)='5' FROM student LIMIT 0, 30' at line 2

The field type is date. MySQL version is 5.1.41.

Any help will be appreciated.

Thanks

4

1 回答 1

6

Move the FROM before the WHERE:

SELECT studentid, fName, lName, dob
FROM student
WHERE MONTH(dob)='5'
于 2013-10-16T19:01:21.027 回答