I want to combine the result of several tables in one result using a column using MySql (see the result), but I am confused about this, if you have any query or optimize the way regarding this, please answer me or the help is definitely appreciated and I myself tried this request with Union , but seriously did not succeed (see example)
Result required
post post_comment_likes post_comments post_likes
2 0 3 0
Inquiry
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"
source
share