我想向select查询发送一个select查询,然后计算结果。
我想做的是这样的事情:
SELECT `word_id`, SUM(`is_core`) as `cores` FROM `table` GROUP BY `word_id` ORDER BY `cores` DESC;
然后我想向上面的查询发送一个选择查询。像这样:
SELECT * FROM `THE QUERY ABOVE` WHERE `cores` >1;
SELECT FOUND_ROWS();
任何帮助将不胜感激。
答案 0 :(得分:0)
试试这个......提供总记录数。
Select count(word_id) from (SELECT `word_id`, SUM(`is_core`) as `cores`
FROM `table` GROUP BY `word_id` ORDER BY `cores` DESC having SUM(`is_core`) > 1)
答案 1 :(得分:0)
为什么使用嵌套查询?单个查询可以获得相同的结果。
SELECT `word_id`, SUM(`is_core`) as `cores`
FROM `table`
GROUP BY `word_id` DESC
HAVING `cores` > 1
ORDER BY `cores`;