该代码在MS SQL Server中运行
SELECT DISTINCT *
FROM (VALUES ('1234'), ('5678'), ('8888'))
AS Table_Staff_No(Staff_No)
WHERE Staff_No
NOT IN (
SELECT Staff_No
FROM Table_Staff_No
WHERE (Staff_No IN ('1234', '5678'. '8888'))
我应该如何在SQLite中进行处理?
我的表的值将为1234,因此我正在传递列表(1234,5678,8888)以检查表中不存在哪个值。
结果应显示为5678、8888。
最佳答案
将此查询转换为SQLite要求common table expression,自SQLite 3.8.3起可用:
WITH Table_Staff_No(Staff_No) AS (
VALUES ('1234'), ('5678'), ('8888')
)
SELECT DISTINCT *
FROM Table_Staff_No
WHERE Staff_No NOT IN (
SELECT Staff_No
FROM Table_Staff_No
WHERE Staff_No IN ('1234', '5678', '8888'));
关于mysql - 从值列表中查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37430025/