How do I retrieve users saved in a database table by field dt_nascimento through two values that represent the minimum and maximum age of users that should be returned, the minimum and maximum age does not always come together can be specified only the minimum age, or only the maximum age. Is subquery required? Note: the database is mysql.
Basically this would be the query (where 18 and 30 are the age limits) the date of birth is in the American AAAA / MM / DD format the where clause is just an example, it does not work.
SELECT nome, dt_nascimento FROM usuario WHERE dt_nascimento > 18 AND dt_nascimento < 30;