有两张表tablea,tableb,
我想把tablea中的数据插到tableb中去。
但前提是tableb中不存在这条数据,该数据关键字有a,b两个字段,
求语句(不想用游标)

解决方案 »

  1.   

    insert into tableb(a,b)
    select a.a,a.b tablea a where not exists (select 1 from tableb b where b.a=a.a and b.b=a.b )这样?
      

  2.   

    忘记了个from
    insert into tableb(a,b)
    select a.a,a.b from tablea a where not exists (select 1 from tableb b where b.a=a.a and b.b=a.b )
      

  3.   

    tablea和tableb的 表结构是怎么样的,需要插什么字段需要说清楚。
      

  4.   

    表结构一样的话insert into tableb select * from tablea a where not exists (select 1 from tableb b where b.a=a.a and b.b=a.b)