Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id |title|images_missing
- 13 |shoes| 0
- 14 |shirt| 0
- id|product_id|color|size|image
- 1 | 13|red |M |0
- 2 | 13|red |XL |1
- 3 | 13|green|M |0
- 3 | 13|green|S |0
- select p.id,p.title,count(1) images_missing
- from products p
- inner join
- (select product_id,color,sum(image)
- from variations
- group by product_id,color
- having sum(image)=0) as v
- on p.id = v.product_id
- group by p.id,p.title
Add Comment
Please, Sign In to add comment