开发者

Combine three select queries?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜