有人知道如何对这样的查询执行COUNT(*)吗?
SELECT reviews.review_id, reviews.reviewers_rating, reviews.reviewers_name, reviews.review_date, reviews.pros, reviews.cons, products.product_name, products.slug, products.community_rating, products.number_of_votes, products.users_rating, products.thumb_link, categories.category_name_single
FROM reviews
LEFT JOIN products ON reviews.product_id = products.product_id
LEFT JOIN categories ON products.category = categories.category_id
WHERE reviews.approved =1
ORDER BY reviews.review_date DESC
谢谢!
最佳答案
试试这个:
SELECT Count(reviews.review_id), reviews.review_id, reviews.reviewers_rating, reviews.reviewers_name, reviews.review_date, reviews.pros, reviews.cons, products.product_name, products.slug, products.community_rating, products.number_of_votes, products.users_rating, products.thumb_link, categories.category_name_single
FROM reviews
LEFT JOIN products ON reviews.product_id = products.product_id
LEFT JOIN categories ON products.category = categories.category_id
WHERE reviews.approved =1
Group By reviews.review_id
ORDER BY reviews.review_date DESC
关于mysql - MySQL如何对具有联接的查询执行COUNT(*)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6279002/