I am calculating the user's age based upon his dob as :
SELECT DATE_FORMAT(FROM_DAYS(DATEDIFF(now(),u.date_of_birth)), '%Y')+0 AS Age from users u ;
And it is giving me the correct age . Now how can I apply condition to . For eg when I am trying to do it,it is giving me error :
SELECT DATE_FORMAT(FROM_DAYS(DATEDIFF(now(),u.date_of_birth)), '%Y')+0 AS Age from users u where age>20;
I know this syntax is incorrect but how can I apply condition to it in mysql and in JPA at Java side.