-1
如何实现这一点:我有一堆数字(例如:2342423; 34443123; 3523423),其中一些在我的数据库表中作为主键值。我只想选择那些不在我的表格中的数字。做这个的最好方式是什么?缺失行,如何选择值
如何实现这一点:我有一堆数字(例如:2342423; 34443123; 3523423),其中一些在我的数据库表中作为主键值。我只想选择那些不在我的表格中的数字。做这个的最好方式是什么?缺失行,如何选择值
如果只是几个数字,你可以做
select tmp.num
from
(
select 2342423 as num
union all
select 34443123
union all
select 3523423
) tmp
left join your_table t on t.id = tmp.num
where t.id is null
如果超过几个数字,你应该插入这些表中并left join
对这个表像这样
select twntc.num
from table_with_numbers_to_check twntc
left join your_table t on t.id = twntc.num
where t.id is null
标签使用了dbms。 (可以使用一些特定的产品技巧。) – jarlh