【发布时间】:2011-08-06 17:09:03
【问题描述】:
如何统计本次查询的结果?
SELECT id FROM table1 where col1 like '%abcd%'
intersect
SELECT id from table2 where col2 like '%efgh%'
【问题讨论】:
标签: database sql-server-2005 select
如何统计本次查询的结果?
SELECT id FROM table1 where col1 like '%abcd%'
intersect
SELECT id from table2 where col2 like '%efgh%'
【问题讨论】:
标签: database sql-server-2005 select
SELECT COUNT(*) FROM
(
SELECT id FROM table1 where col1 like '%abcd%'
intersect
SELECT id from table2 where col2 like '%efgh%'
) I
其中I 是“派生”表的别名。在这种情况下,它没有做任何重要的事情,但需要 SQL 来识别语法 - 否则,您将收到“')' 附近的语法错误”错误。
【讨论】: