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 PROGRAM_ID =713 and substr(STUDENT_ID,9,1) = ORDER BY STUDENT_ID ASC LIMIT ' at line 1