Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. SELECT p.image, p.product_id,
  2. (select text from product_attribute pa WHERE pa.product_id=p.product_id and attribute_id=47) attrribute47,
  3. (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,
  4. (select count(distinct pi.product_image_id) from product_image pi where p.product_id=pi.product_id) cnt_img
  5.  
  6. FROM `product` p
  7. where
  8. (
  9. (
  10. (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
  11. (coalesce((select text from product_attribute pa WHERE pa.product_id=p.product_id and attribute_id=47),'')<>'да')
  12. )
  13. OR
  14. (
  15. (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
  16. (coalesce((select text from product_attribute pa WHERE pa.product_id=p.product_id and attribute_id=47),'')='да')
  17. )
  18. )
  19. and p.product_id = 1809
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement