How to insert records from table to another without duplicate

后端 未结 5 1656
小鲜肉
小鲜肉 2021-01-21 17:01

I have two tables t1 and t2. t1 has duplicated values. I need to insert all records from t1 to t2, but I don\'t want duplicates to occur in t2. I tried the following command whi

5条回答
  •  深忆病人
    2021-01-21 17:28

    I need to insert data from user to another user and when write this statement .....

    insert into trep12.jobhead
    select
    *
    from
    wsfin04.jobhead
    where
    wsfin04.jobhead.job_no not in (select job_no from trep12.jobhead)
    and wsfin04.jobhead.CHASS_NO not in (select CHASS_NO from trep12.jobhead)
    and rdate between '01-jul-15'
    and '01-oct-15'
    and job_type = 1;
    

    ..... the result is 0 rows created.

提交回复
热议问题