Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取不匹配的值连接sql中的两个表_Sql_Join_Left Join - Fatal编程技术网

获取不匹配的值连接sql中的两个表

获取不匹配的值连接sql中的两个表,sql,join,left-join,Sql,Join,Left Join,“表1”-->boodang_iphone包含--3000条记录 “table2”->boodang_iphonePushtest05302012表格包含--90条记录 我需要在'boodang_iphonePushtest05302012'比较表1中得到不匹配的值,我这样写查询 SELECT boodang_iphonePushtest05302012.devicetoken FROM boodang_iphonePushtest05302012 left outer join boodan

“表1”-->boodang_iphone包含--3000条记录

“table2”->boodang_iphonePushtest05302012表格包含--90条记录

我需要在'boodang_iphonePushtest05302012'比较表1中得到不匹配的值,我这样写查询

SELECT boodang_iphonePushtest05302012.devicetoken 
FROM boodang_iphonePushtest05302012
left outer join boodang_iphone  on 
    boodang_iphone.devicetoken=boodang_iphonePushtest05302012.devicetoken 
where 
    boodang_iphonePushtest05302012.devicetoken != boodang_iphone.devicetoken

我很困惑是它提供了正确的数据还是没有任何人可以我们请引导我使用联接获取不匹配值

此查询提供存在于
boodang\u iphonePushtest05302012
中但不存在于
boodang\u iphone
中的所有记录。但是,您需要通过交换表再次运行查询,因此它将为您提供
boodang_iphone
中存在的所有记录,而不是
boodang_iphonePushtest05302012
(相反,您可以使用相同的查询,但通过右外连接连接表)。那么你应该得到比较的全部结果

如果可以将where子句更改为

where boodang_iphone.devicetoken IS NULL
那就更好了。这是因为如果值不匹配,那么它将从第二个表返回NULL值,并且如果将NULL值与有效数据进行比较,它总是有问题