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
Basically - in order to compare two SQLite database files, you need to click the "Compare..." button. This will open up the "Comparison Details" dialog in which you'll fill in the paths to both SQLite database files and choose the comparison mode: Compare schema only- For comparing only SQL schema differences.
Using joins to compare columns by priority among the table. For example, left join returns all values from the first table and null value for the not-matched records from the second table. Similarly, we can use right join, inner join, full join and self join as per our requirements.
SELECT DISTINCT Field1
FROM Table1
WHERE Field1 Not IN
(SELECT DISTINCT Field1 FROM Table2)
SELECT columns1 FROM table1 EXCEPT SELECT columns2 FROM table2;
The SQLite EXCEPT clause returns all rows from the left SELECT statement that are not in the result of the second SELECT statement. The number of columns selected must be the same in both SELECT statements.
This works fine for small to medium size tables. Avoid for tables with millions of lines.
See Compound Select Statements and the documentation of the SQLite SELECT statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With