Skip to content

how to insert into table with preselected values from a minus query?

I get specific values by using a statement like

select id from x minus (select id from y)

it returns multiple rows which I all need to insert into another table. How do I achieve this?

I tried something like this which didnt work:

insert into table (id, name) values((select id from x minus (select id from y), 'name')

so the table in the end has all values I got before plus another column with ‘name’ in it.

Any help is appreciated. Thanks


Just use :

insert into yourFinalTable(id, name)
select id, 'name' from x minus select id, 'name' from y;