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 d.id_id in (select d.id_id from cp_image_data d left join cp_image i on d.id' at line 1
select d.id_id,d.id_credit,d.id_description,d.id_caption,d.createdTime,i.i_ext from cp_article_image ai left join cp_image_data d on ai.id_id=d.id_id left join cp_image i on d.id_id=i.id_id where ai.a_id= and d.id_id in (select d.id_id from cp_image_data d left join cp_image i on d.id_id=i.id_id where i.ic_id = 2 and d.id_gallery=1) and i.ic_id=3 order by createdTime desc limit 1