I created a table A
and B
with same exact columns:
create or replace table a (
a1 varchar(30),
a2 int,
a3 int
);
create or replace table b (
b1 varchar(30),
b2 int,
b3 int
);
And then inserted 2 values in each:
insert into a values ('abc', 1, 2);
insert into a values ('abd', 1, 2);
insert into b values ('abd', 1, 2);
insert into b values ('abe', 1, 2);
How to make insert statement so that it inserts only records from B
that do NOT exist in table A
(by e.g. using join statement?)?
insert into table a (
select * from b
);
(without Primary Key help).
Bonus point is to check only on 2 columns if they are the same or not (e.g. a1 != b1
and a2 != b2
).
Thanks!