Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/80.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
Mysql 如何获取(我的)SQL表中不存在的ID列表?_Mysql_Sql_Select - Fatal编程技术网

Mysql 如何获取(我的)SQL表中不存在的ID列表?

Mysql 如何获取(我的)SQL表中不存在的ID列表?,mysql,sql,select,Mysql,Sql,Select,我有一个MySQL表,如下所示: +----+ | id | +----+ | a | | c | | e | +----+ select ids.id from (select 'a' as id union all select 'b' union all select 'c' union all select 'd' union all select 'e' ) ids where ids.id not in (select id from t); 我想检查

我有一个MySQL表,如下所示:

+----+
| id |
+----+
| a  |
| c  |
| e  |
+----+
select ids.id
from (select 'a' as id union all select 'b' union all select 'c' union all
      select 'd' union all select 'e'
     ) ids
where ids.id not in (select id from t);
我想检查以下哪个ID
a
b
c
d
e
在表中不存在

也就是说,我想得到一个id
b
d
的列表


我是否可以手工构造一个查询,返回我的表中不存在的ID列表,而不实际创建新的第二个永久SQL表?

这通常使用
左连接或类似的方法来完成:

+----+
| id |
+----+
| a  |
| c  |
| e  |
+----+
select ids.id
from (select 'a' as id union all select 'b' union all select 'c' union all
      select 'd' union all select 'e'
     ) ids
where ids.id not in (select id from t);

如果列表已经在表中,则可以使用该表(或子查询)而不是派生表。

使用哪个RDBMS…?作为标题和指定的问题;MySQL=)