Question

I have two tables A(column1,column2) and B(column1,column2).

How to ensure that a value from A(column1) is not contained within B(column1) and insert it in this column.

My Query will be like this :

insert into B.column1 values()  
 where
...  

I want to complete B.column1 with data from A.column1

What should i put in the where clause ?

Was it helpful?

Solution

Insert Into B(column1)
Select A.Column1
From A
Where A.Column1 not in (Select Column1 From B)

OTHER TIPS

I would use MINUS command and select all rows from A(column1) which are not in B(column1) and then SELECT INTO result into B table.

insert into B
select a.column1, a.column2 from a
left join b
on a.column1 = b.column1
where b.column1 is null
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top