Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use plant_service;
- select o.user_id,u.first_name,count(i.id) as `orders` from users as u
- join orders o on o.user_id=u.id
- join plants_orders po on po.order_id=o.id
- join plants p on po.plant_id=p.id
- join info_plants ip on ip.plant_id=p.id
- left join orders i on i.user_id=u.id
- where (ip.genus="Begonia")
- group by first_name
- order by `orders` desc,first_name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement