Skip to content
Advertisement

Comparing two tables in SQLite

I have two tables and want to compare rows on sqlite like this

table1           table2
field1           field1

a                   a
b                   d
c                   f
d                   g
e
f
g
h
i

and I want to produce result like this

result_table
field1

b
c
e
h
i

How is the syntax in sqlite? Thanks

Advertisement

Answer

SELECT DISTINCT Field1
FROM Table1 
WHERE Field1 Not IN 
    (SELECT DISTINCT Field1 FROM Table2)
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement