Guest User

Untitled

a guest
Jan 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. id |title|images_missing
  2. 13 |shoes| 0
  3. 14 |shirt| 0
  4.  
  5. id|product_id|color|size|image
  6. 1 | 13|red |M |0
  7. 2 | 13|red |XL |1
  8. 3 | 13|green|M |0
  9. 3 | 13|green|S |0
  10.  
  11. select p.id,p.title,count(1) images_missing
  12. from products p
  13. inner join
  14. (select product_id,color,sum(image)
  15. from variations
  16. group by product_id,color
  17. having sum(image)=0) as v
  18. on p.id = v.product_id
  19. group by p.id,p.title
Add Comment
Please, Sign In to add comment