user2562841
user2562841

Reputation: 73

sqlite query from list of value

This code is working within 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'))

How should I go about it in SQLite?

My table will be have value 1234, so I am passing my list (1234,5678,8888) to check which value is not exist in my table.

The result should be show 5678, 8888.

Upvotes: 2

Views: 5371

Answers (1)

CL.
CL.

Reputation: 180070

Translating this query to SQLite requires a common table expression, which is available since 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'));

Upvotes: 3

Related Questions