1. 程式人生 > >Mysql 對比兩張表資料

Mysql 對比兩張表資料

檢視一個表中的資料是否在另一個表中存在

第一種方案:
select  *  from  tb_a   A  where  NOT EXISTS (select 1 from tb_b  B  where  A.ID = B.ID);

第二種方案:
select  *  from  tb_a   A  where  A.ID  NOT IN(select  B.ID  from tb_b  B );