table1-table2:select * from table1 where not exists(select 1 from table2 where table1.列1=table2.列1 and table1.列2=table2.列2 and table1.列3=table2.列3,...,table1.列n=table2.列n)
Select * from 表a where 主键 exists (select 1 from 表b where 主键<>表a.主键)
agree: select * from table1 where not exists(select 1 from table2 where table1.列1=table2.列1 and table1.列2=table2.列2 and table1.列3=table2.列3,...,table1.列n=table2.列n)1。如果这两个表没有主键怎么做? select * from table1 where not exists(select 1 from table2 where table1.列1=table2.列1 and table1.列2=table2.列2 and table1.列3=table2.列3,...,table1.列n=table2.列n)2。如果这两个表有两个以上的主键怎么做? select * from table1 where not exists(select 1 from table2 where table1.列1=table2.列1 and table1.列2=table2.列2 and table1.列3=table2.列3,...,table1.列n=table2.列n)
1。如果这两个表没有主键怎么做?
2。如果这两个表有两个以上的主键怎么做?
希望能一句话实现,谢谢
select * from table1 where not exists(select 1 from table2 where table1.列1=table2.列1 and table1.列2=table2.列2 and table1.列3=table2.列3,...,table1.列n=table2.列n)1。如果这两个表没有主键怎么做?
select * from table1 where not exists(select 1 from table2 where table1.列1=table2.列1 and table1.列2=table2.列2 and table1.列3=table2.列3,...,table1.列n=table2.列n)2。如果这两个表有两个以上的主键怎么做?
select * from table1 where not exists(select 1 from table2 where table1.列1=table2.列1 and table1.列2=table2.列2 and table1.列3=table2.列3,...,table1.列n=table2.列n)