copying from one table to another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cmrhema
    Contributor
    • Jan 2007
    • 375

    copying from one table to another

    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<>empc heck1.empid

    But it gave me an error
  • deepuv04
    Recognized Expert New Member
    • Nov 2007
    • 227

    #2
    Originally posted by cmrhema
    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<>empc heck1.empid

    But it gave me an error
    hi

    try the following query
    [code=sql]
    insert into empcheck1(colum n1,column2,...)
    select column1,column2 ,... from emp
    where emp.empid not in (select empid from empcheck1)

    [/code]
    thanks

    Comment

    Working...