You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') order by h.hotel_name' at line 1 select * from dm_hotel_contact_details h left join dm_hotel_website_content dh on(h.hid=dh.hid) where h.status=1 and h.hid in () order by h.hotel_name