SELECT * FROM ls_advert WHERE ifshow=1 and stime<=1488193525 AND etime>=1488193525 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