Error: Invalid query: 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 contract.cutoffdate >= curdate()' at line 1 Whole query: select contract_room.*,hotel_room.description as hr_desc, hotel_room.disclaimer, room_type.room_code, contract.cutoffdate, room_type.description from contract_room left join contract on (contract.contract_id = contract_room.contract_id) left join hotel_room on (hotel_room.h_r_id = contract_room.h_r_id) left join room_type on (room_type.room_id = hotel_room.room_id) where status > 0 and contract_room.h_r_id > 0 and contract_room.contract_id = and contract.cutoffdate >= curdate()