select, p.basename, p.code, p.prettyurl, as brandname,p.valuebuy, p.sales, case when 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 inner join cnt_productcolor pc on and pc.fk_color=p.fk_firstcolor inner join cnt_productitem i on left join cnt_productcolor selectpc on and selectpc.fk_color=0 left join cnt_productcolorimage pci on selectpc.fk_firstimage,pc.fk_firstimage) where 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