Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting non duplicate values

Status
Not open for further replies.

Dabase

Programmer
Apr 2, 2004
122
PT
Hi,

I have 2 tables as follows:

MyTable
-------
Australia
USA
UK

OtherTable
----------
Australia
Argentina
Armenia
Ukraine
Uganda
USA
UK


I need to insert the values from OtherTable into MyTable without creating any duplications.

Any ideas how I can go about doing this?

Thanks
Dabase
 
something like this
insert into MyTable
select * from OtherTable o
where not exists(select * from MyTable m where o.Country =m.Country)

or

insert into MyTable
select * from OtherTable o left join
MyTable m on o.Country =m.Country
where m.Country is null



Denis The SQL Menace
SQL blog:
Personal Blog:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top