1

假设我有一个查询,例如

SELECT * from frequency where (...) 
UNION 
SELECT * from frequency where  (...)

我如何计算上面返回了多少结果?

4

2 回答 2

5

使用COUNT()带有子查询的函数

SELECT COUNT(*) AS Row_Counts
FROM 
(
  SELECT * from frequency where (...) 
  UNION 
  SELECT * from frequency where  (...)
) A
于 2013-05-16T11:57:48.720 回答
1

为什么UNION?如果你结合WHERE子句,你可以这样计算:

SELECT COUNT(*)
FROM frequency 
WHERE (...) OR (...)
于 2013-05-16T12:02:10.747 回答