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 reg_type = 2 and com_start_date <= '2014-09-20' and com_end_date >= '2014-09' at line 1