select p.id, p.basename, p.code, p.prettyurl, b.name as brandname,p.valuebuy, p.sales, case when selectpc.id is not null then selectpc.fk_color else p.fk_firstcolor end as selectedcolor, pci.listingimage, p.discountprice, p.price, case when sum(i.qty)>0 then 0 else 1 end as soldout, case when coalesce( p.discountprice,0)=0 then p.price else p.discountprice end as sellingprice from cnt_product p inner join cnt_brand b on b.id=p.fk_brand inner join cnt_productcolor pc on pc.fk_product=p.id and pc.fk_color=p.fk_firstcolor inner join cnt_productitem i on i.fk_product=p.id left join cnt_productcolor selectpc on selectpc.fk_product=p.id and selectpc.fk_color=0 left join cnt_productcolorimage pci on pci.id=coalesce( selectpc.fk_firstimage,pc.fk_firstimage) where p.id= and p.status='Active'
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 p.status='Active'' at line 1