我想知道如何编写SQL语句来判断表A中的行数是否等于表B中的行数?
答案 0 :(得分:2)
查询以下内容
SELECT 1
FROM
(SELECT COUNT(1) TOTAL_A FROM A) TABLE_A_COUNT,
(SELECT COUNT(1) TOTAL_B FROM B) TABLE_B_COUNT
WHERE TABLE_A_COUNT.TOTAL_A = TABLE_B_COUNT.TOTAL_B
如果计数匹配,它将返回一行。
答案 1 :(得分:0)
if (select count(*) from a) = (select count(*) from b)
begin
:
end