1、SELECT * FROM t2 WHERE id NOT IN (SELECT id FROM t1) 2、SELECT * FROM t2 WHERE NOT EXISTS(SELECT * FROM t1 WHERE t1.id=t2.id) 3、SELECT t2.* FROM t2 LEFT JOIN t1 ON t2.id=t1.id WHERE t1.id is null 三种方法都得不到所想要的不同内容的结果(VB编程,语法正确,结果为空),崩溃了。 我有表1=Standard_Data1 ,表2=Standard_Data2,两个表里面只有1列数据为MSISDN,下面SQL语句没法找到不同的内容。 select * from Standard_Data1 where Standard_Data1.MSISDN not IN(select Standard_Data2.MSISDN from Standard_Data2) select * from Standard_Data1 where not exists(select * from Standard_Data2 where Standard_Data1.MSISDN=Standard_Data2.MSISDN) 更新: distinct是关键,在select后面加上这个就成功了。另外,最快的查找方法是下面这2条,之所以是2条因为要找两次才能找全互相不同的数据: select distinct Standard_Data1.* from Standard_Data1 left join Standard_Data2 on Standard_Data1.MSISDN=Standard_Data2.MSISDN where Standard_Data2.MSISDN is NULL select distinct Standard_Data2.* from Standard_Data2 left join Standard_Data1 on Standard_Data2.MSISDN=Standard_Data1.MSISDN where Standard_Data1.MSISDN is NULL 找相同内容的语句就很容易就出正确的结果了,如下: select distinct Standard_Data1.* from Standard_Data1 inner join Standard_Data2 on Standard_Data1.MSISDN=Standard_Data2.MSISDN