我需要计算查询的计数,但是我遇到了一些问题。
原始查询运行良好。
它给了我 1 行的正确计数(3200):
select count(e.entity_id)
from `catalog_product_entity` AS `e`
INNER JOIN `review` AS `rt`
ON rt.entity_pk_value = e.entity_id
INNER JOIN `review_detail` AS `rdt`
ON rdt.review_id = rt.review_id
INNER JOIN `review_store` AS `store`
ON rt.review_id=store.review_id AND store.store_id=0
我需要更改此查询以获取其他值,所以现在,这是新的计数查询:
select count(e.entity_id)
from `catalog_product_entity` AS `e`
INNER JOIN `review` AS `rt`
ON rt.entity_pk_value = e.entity_id
INNER JOIN `review_detail` AS `rdt`
ON rdt.review_id = rt.review_id
LEFT JOIN `rating_option_vote` AS `vt`
ON vt.review_id = rt.review_id
INNER JOIN `review_store` AS `store`
ON rt.review_id=store.review_id AND store.store_id=0
GROUP BY `rt`.`review_id`
第二个查询给我的不是 1 行具有正确计数 (3200),而是 3200 行,每行具有不同的计数。
我需要的是这样的:
SELECT COUNT (*) FROM
( `second_query`)
或任何其他让我恢复正确计数的解决方案