1 つの共通キーを使用して、各テーブルの合計列をカウントしようとしています。ユニオンステートメントでできます。結合の使用方法
クエリ:
SELECT count(id) As WOWcount FROM `wow_track` where author_post_id='882' union SELECT count(*) As Followcount FROM `FolllowUserPost` where postID='882' union SELECT count(*) As CommentCount FROM `f9pix_comments` where post_id_fk ='882' union SELECT count(*) As ViewCount FROM `viewPhotosTrack` where postID='882'
次のクエリを使用しました:
SELECT COUNT(a.author_post_id) AS WOWcount, COUNT(b.postID) AS Followcount, COUNT(c.post_id_fk) AS CommentCount, COUNT(d.postID) As ViewCount
FROM wow_track a
LEFT JOIN FolllowUserPost b ON a.author_post_id = b.postID
LEFT JOIN f9pix_comments c ON b.postID = c.post_id_fk
LEFT JOIN viewPhotosTrack d ON c.post_id_fk = d.postID
WHERE a.author_post_id='882'
しかし、間違ったカウントを表示しています