SQL Server - 使用带有intersect的count函数

时间:2011-04-16 00:17:00

标签: database sql-server-2005 select

如何计算此查询的结果?

SELECT id FROM table1 where  col1 like '%abcd%'
intersect
SELECT id from table2 where col2 like '%efgh%'

1 个答案:

答案 0 :(得分:24)

SELECT COUNT(*) FROM
(
 SELECT id FROM table1 where  col1 like '%abcd%'
 intersect
 SELECT id from table2 where col2 like '%efgh%'
) I