I need to synchronize two tables. Suppose the tables contain the following columns:
Table1: A, B, C, D Table2: A, B, C, E
I need to find such rows in table 1 that in table 2 there are no records with corresponding values (A, B, C) , and then E is calculated as F (D) and update table 2.
If I need to match, for example. only A, I would write the following query:
SELECT * FROM Table1 WHERE A NOT IN (SELECT A FROM Table2)
The multi-column counterpart seems too slow:
SELECT * FROM Table1 WHERE A NOT IN (SELECT A FROM Table2) AND B NOT IN (SELECT B FROM Table2) AND C NOT IN (SELECT C FROM Table2)
What is the best way to write such a query?
sql oracle
levanovd
source share