SELECT * FROM ls_advert WHERE ifshow=1 and stime<=1496029370 AND etime>=1496029370 AND sub=105 AND city= order by orderby 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 'order by orderby' at line 1