2013-05-16 77 views

回答

5

使用COUNT()功能與子查詢

SELECT COUNT(*) AS Row_Counts 
FROM 
(
    SELECT * from frequency where (...) 
    UNION 
    SELECT * from frequency where (...) 
) A 
1

爲什麼UNION?如果結合WHERE條款,你可以得到數是這樣的:

SELECT COUNT(*) 
FROM frequency 
WHERE (...) OR (...) 
+3

是,要簡單得多,但應注意的是,這將只與UNION而不是UNION ALL工作... – Ben