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 'AND class2.class2_id= AND user1.userid=class2.class2_manager ORDER BY table3.tab' at line 1