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
精彩评论