表1   id,xm,pid,cid
表2   id,xm,jk,tw,cid,pid比如这样 然后现在要从表2的xm插入到表1的xm  两个表只有pid是一样的

解决方案 »

  1.   

    update a set xm=b.xm
    from 表1 a,表2 b
    where a.id=b.id
      

  2.   

    什么条件啊insert 表1
    select id,xm,pid,cid from 表2????????
      

  3.   

    update 表1 set xm=表2.xm from 表2 bwhere 表1.id=表2.id
      

  4.   

    update a set xm=b.xm
    from 表1 a,表2 b
    where a.pid=b.pid
      

  5.   

    update a set xm=b.xm 
    from 表1 a 
    join 表2 b on a.pid=b.pid
      

  6.   

    1L和3L的应该可以实现,不过把id改为pid
      

  7.   

    update 表1 set xm=表2.xm from 表2 bwhere 表1.id=表2.id
    不过,如果表1中没有表2的pid就该插入进去了
      

  8.   

    insert 表1(id,xm,cid,pid)
    select id,xm,cid,pid from 表2 as a where not exists(select 1 from 表1 where Pid=a.Pid)插入用以上方法,如果存在时更新用楼上的方法