开发者

Combine three select queries?

开发者 https://www.devze.com 2023-02-07 12:06 出处:网络
I would like to combine these three sql queries SELECT homeupload, COUNT(*) F开发者_C百科ROM link GROUP BY homeupload

I would like to combine these three sql queries

SELECT homeupload, COUNT(*) F开发者_C百科ROM link GROUP BY homeupload
SELECT mediaType, COUNT(*) FROM link GROUP BY mediaType
SELECT emailSub, COUNT(*) FROM link WHERE emailSub='1' GROUP BY emailSub

Into a single queries. Is this possible?


Try using UNION

SELECT homeupload, COUNT(*) FROM link GROUP BY homeupload
UNION 
SELECT mediaType, COUNT(*) FROM link GROUP BY mediaType
UNION 
SELECT emailSub, COUNT(*) FROM link WHERE emailSub='1' GROUP BY emailSub

Reference

0

精彩评论

暂无评论...
验证码 换一张
取 消