SELECT bp.postID, bp.postTitle, bp.postSlug, bp.authorName,bp.coverPic, bp.postDesc, bp.postDate FROM blog_posts bp INNER JOIN blog_post_cats bpc ON bp.postID=bpc.postID INNER JOIN blog_cats bc ON bpc.catID=bc.catID WHERE bp.STATUS=1 AND catSlug="World-In-360" ORDER BY postID DESC
此查询两次获取每一行。对此有何帮助?
答案 0 :(得分:-1)
您只需要添加GROUP BY
SELECT bp.postID, bp.postTitle, bp.postSlug, bp.authorName,bp.coverPic, bp.postDesc, bp.postDate
FROM blog_posts bp
INNER JOIN blog_post_cats bpc
ON bp.postID=bpc.postID
INNER JOIN blog_cats bc
ON bpc.catID=bc.catID
WHERE bp.STATUS=1 AND catSlug="World-In-360"
GROUP BY postID
ORDER BY postID DESC