数据库两个表记录互相比较

Aa中有几条数据时bb表中没有的
SELECT count(*) count1
            FROM aa t
           WHERE  not exists
           (select 1 from bb i where i.b1 =t.b1)


Aa中有几条数据时bb表中有的
SELECT count(*) count1
            FROM aa t
           WHERE  exists
           (select 1 from bb i where i.b1 =t.b1)

你可能感兴趣的:(数据库,数据比较)