Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT p.image, p.product_id,
- (select text from product_attribute pa WHERE pa.product_id=p.product_id and attribute_id=47) attrribute47,
- (select count(distinct pi.photo_templates_id) from product_image pi join photo_templates pt on pi.photo_templates_id=pt.photo_templates_id where p.product_id=pi.product_id) cnt_tpl,
- (select count(distinct pi.product_image_id) from product_image pi where p.product_id=pi.product_id) cnt_img
- FROM `product` p
- where
- (
- (
- (select count(distinct pi.photo_templates_id) from product_image pi join photo_templates pt on pi.photo_templates_id=pt.photo_templates_id where p.product_id=pi.product_id)< (select count(*) from photo_templates) AND
- (coalesce((select text from product_attribute pa WHERE pa.product_id=p.product_id and attribute_id=47),'')<>'да')
- )
- OR
- (
- (select count(distinct pi.photo_templates_id) from product_image pi join photo_templates pt on pi.photo_templates_id=pt.photo_templates_id where p.product_id=pi.product_id)< (select count(*) from photo_templates) * 3 AND
- (coalesce((select text from product_attribute pa WHERE pa.product_id=p.product_id and attribute_id=47),'')='да')
- )
- )
- and p.product_id = 1809
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement