The link above have helped me how to calculate difference in two dates, however, I need to do the same on a particular column at run time via MySQL select query inside PHP.
For example:
Profile table:
- Name
- Gender
- DOB (Date of Birth)
Running following query via MySQL console, gives exactly the needed result:
SELECT TIMESTAMPDIFF(YEAR, DOB, CURDATE()) AS Age FROM profile;
However, I need to complete the following query to get me the same result combined with other conditions on whole set of DOB values:
SELECT * FROM Profile WHERE Gender='$gn';
I checked Sub-query but that, wont work due to more than one return value.