I have a table FinalTable
with these columns:
name, lastName, pesel, position, id_operator
I want to fill my FinalTable
with values from 2 other tables:
- AAA - this table has columns like name, lastName, pesel, position
- BBB - this table has columns name, id_operator, pesel
I want to join AAA
and BBB
on the pesel
column
insert into FinalTable (name, lastName, pesel, position, id_operator)
select
name, lastName, pesel, position,
(select id_operator from BBB b where b.pesel = a.pesel)
from
AAA a;
How to do that? I'd like to set my last column id_operator
to the value from BBB
. The SQL query above is incorrect.