我有一个像这样的查询
SELECT row1, row2
FROM (
SELECT b.row21, COUNT(b.row21) AS hits
FROM table2 AS b
WHERE b.row22 = 'foo' OR b.row22 = 'bar'
GROUP BY b.row21
HAVING hits = 2
) AS b
INNER JOIN table1 AS a ON (b.row21 = a.row1)
WHERE row2 = 123
LIMIT 10
现在很明显,结果首先受到附加限制WHERE
,最后受到限制LIMIT
。
那么如何在不需要单独执行的情况下检索子查询返回的行数呢?