In the users table I have a field called dob which stores the date of birth of the user in this format:
1959-04-02
Anyway I would like to SELECT all users who are 18 and 19 years old. This is my query:
SELECT *
FROM `users`
WHERE dob BETWEEN '1993-10-30' AND '1994-10-30'
But it only seems to select mostly 18 year olds and some (but not all) 19 year olds. I have a bunch of test users in the db and the number of 18 and 19 year olds are equal. Yet this query yields about 90% 18 year olds and about 10% 19 year olds. Why?
People who are between 18 and 19 years old encompass a range of birthdates over 2 years. Your query only covers 1 year. Consider reworking your logic.