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 id' at line 1 Q=SELECT * FROM business_directory_operating_hours WHERE business_id = ORDER BY id