MySQL Query to get age from date of birth -
i have issue query,
select id, pseudo, nom, prenom, sexe, ville, floor(datediff (now(), date_naissance)/365) mage user sexe = 'homme' , mage between 18 , 25 or ville = 'bordeaux' it supposed return matching user condition. problem following, mage not existing following error :
1054 - unknown column 'mage' in 'where clause'
looks alias not working on condition.
if remove mage clause, mage alias.
i need guys
thanks in advance !
you can not use column aliases in clauses: http://dev.mysql.com/doc/refman/5.0/en/problems-with-alias.html.
you have rethink query or change to:
select id, pseudo, nom, prenom, sexe, ville, floor(datediff (now(), date_naissance)/365) mage user sexe = 'homme' , floor(datediff (now(), date_naissance)/365) between 18 , 25 or ville = 'bordeaux' ps may want have @ ands , ors might want include brackets.
Comments
Post a Comment