By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,378 Members | 1,407 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,378 IT Pros & Developers. It's quick & easy.

copying from one table to another

100+
P: 375
Hi,

I have two tables emp and empcheck1 in the same database

emp consits 50 records
and empcheck1 consists of 25 records

Both the tables have the same design, here empid is the unique key

I want to insert all the datas from emp1 to empcheck1 in such a way that it should not rewrite or duplicate the original 25 records

Whatever 25 records are there in empcheck1 already exists in emp

So i want the rest of the 25 odd records to be copied to empcheck1 from emp


Can anyone let me know how to do that
i tried out
insert into empcheck1 select * from emp where emp.empid<>empcheck1.empid

But it gave me an error
May 20 '08 #1
Share this Question
Share on Google+
1 Reply


deepuv04
Expert 100+
P: 227
Hi,

I have two tables emp and empcheck1 in the same database

emp consits 50 records
and empcheck1 consists of 25 records

Both the tables have the same design, here empid is the unique key

I want to insert all the datas from emp1 to empcheck1 in such a way that it should not rewrite or duplicate the original 25 records

Whatever 25 records are there in empcheck1 already exists in emp

So i want the rest of the 25 odd records to be copied to empcheck1 from emp


Can anyone let me know how to do that
i tried out
insert into empcheck1 select * from emp where emp.empid<>empcheck1.empid

But it gave me an error
hi

try the following query
Expand|Select|Wrap|Line Numbers
  1. insert into empcheck1(column1,column2,...)
  2.  select column1,column2,... from emp 
  3. where emp.empid not in (select empid from empcheck1)
  4.  
  5.  
thanks
May 20 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.