用联合mysql选择查询分组

用联合mysql选择查询分组,第1张

联合mysql选择查询分组
select sum(qty), namefrom (    select count(m.owner_id) as qty, o.name    from transport t,owner o,motorbike m    where t.type='motobike' and o.owner_id=m.owner_id        and t.type_id=m.motorbike_id    group by m.owner_id    union all    select count(c.owner_id) as qty, o.name,    from transport t,owner o,car c    where t.type='car' and o.owner_id=c.owner_id and t.type_id=c.car_id    group by c.owner_id) tgroup by name


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5053242.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-15
下一篇 2022-11-16

发表评论

登录后才能评论

评论列表(0条)

保存