MySQL查询返回未在另一个表中列出的行

时间:2013-04-09 09:59:18

标签: mysql sql phpmyadmin

我在MySQL DB PHPMyAdmin中有两个表:

Table-1: T1

enter image description here

Table-2: T2

enter image description here

我需要编写一个mysql查询,它将返回T1中未列在T2中的所有IMEI。

例如,在这种情况下,查询应返回123456781235176

感谢。

5 个答案:

答案 0 :(得分:1)

试试这个select IMEI from T1 where IMEI not in (select IMEI from T2);

答案 1 :(得分:0)

SELECT t1.* FRO table1 AS t1
LEFT JOIN table2 AS t2 ON t1.IMEI = t2.IMEI
WHERE t2.IMEI IS NULL

答案 2 :(得分:0)

尝试此查询

Select EMEI from t1 where EMEI not in (select EMEI from t2)

答案 3 :(得分:0)

select IMEI from T1 where IMEI not in 
(
    select a.IMEI from T1 as a inner join T2 as b on a.IMEI = b.IMEI
) as exp

希望这会对你有所帮助

答案 4 :(得分:0)

SELECT IMEI FROM T1 WHERE IMEI NOT IN(SELECT IMEI FROM T2);