SELECT *, greatest(YEAR,YEAR_EVAL) as YEAR_SELECT FROM PLACE WHERE STREET LIKE '224, place D'Youville' AND CITY =1 ORDER BY cast(ADDRESS as unsigned) ASC LIMIT 10000 Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Youville' AND CITY =1 ORDER BY cast(ADDRESS as unsigned) ASC LIMIT 10000' at line 1