此代码在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。
答案 0 :(得分:0)
将此查询翻译为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'));