Answer the question
In order to leave comments, you need to log in
How to compare 2 tables and display an id that is not in the second table?
Hello, there are 2 tables
test1
id
name
test2
id
test_id
type
name_test2
Answer the question
In order to leave comments, you need to log in
insert into test2 (test_id, type)
select test.id, type_value from test1
join (
select 1 as type_value
union all
select 2
) as types ON TRUE -- нужно декартово произведение
where not exists (select 1 from test2 where test2.test_id = test.id)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question