我想使用MySql将多个表的结果计数与列明智的结果结合起来(请参阅所需的结果),但如果您对此有任何查询或优化方式,我对此感到困惑,请回答我或帮助,我也试过了我自己这个查询与联合但严重不成功(请参阅查询示例)
需要结果
post post_comment_likes post_comments post_likes
2 0 3 0
询问
SELECT COUNT(*) AS `post` FROM post WHERE user_id = "123456" UNION
SELECT COUNT(*) AS `post_comment_likes` FROM post_comment_likes WHERE user_id = "123456" UNION
SELECT COUNT(*) AS `post_comments` FROM post_comments WHERE user_id = "123456" UNION
SELECT COUNT(*) AS `post_likes` FROM post_likes WHERE user_id = "123456"