如何统计本次查询的结果?
SELECT id FROM table1 where col1 like '%abcd%'
intersect
SELECT id from table2 where col2 like '%efgh%'
最佳答案
SELECT COUNT(*) FROM
(
SELECT id FROM table1 where col1 like '%abcd%'
intersect
SELECT id from table2 where col2 like '%efgh%'
) I
I
是“派生”表的别名。在这种情况下,它不会做任何重要的事情,但 SQL 需要在那里识别语法 - 否则,您将收到“')' 附近的不正确语法”错误。
关于database - SQL Server - 使用带交集的计数函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5683556/