Yes, this may sound strange.
In the advanced profile searching form, where you can filter by age.
Now you would type 18 or some other age in the field.
I am storing the birthdays, in the mysql db, in the birthday field in users i have example: 1990-02-02
How can i filter by age then, in a query?
Should i first make a query before, make all users birthdays to age, and then compare them? Would be too much, to take each one user.
I bet this is what you are searching for:
SELECT * FROM mytable
WHERE TIMESTAMPDIFF(YEAR, mytable.birthday,'$currentTime') > '$ageFromForm';
To sort the data you would perform this :
SELECT *, (TIMESTAMPDIFF(YEAR, mytable.birthday, '$currentTime')) AS age
FROM mytable WHERE TIMESTAMPDIFF(YEAR,'$birthday','$currentTime') > '$ageFromForm'
ORDER BY age;
I hope this helps ;)
Slavic
Untested, but should work as a basis to start from:
SELECT <columns> FROM users WHERE birthday < SUBDATE(NOW(), INTERVAL 18 YEAR)