有两张表:
    
     表 a                       表    b
empid(主键) computerid           computerid(主键)   empid
   1           001                   001           
   2           003                   002
   3           002                   003
   4           004                   004我的问题:
如何把表 b的empid值修改成表 a的empid值,目的:当表a与表b的computerid相同时,将表a的empid值赋给表b的empid

解决方案 »

  1.   

    update b
    set empid=(
    )
      

  2.   

    发贴格式乱了
            表 a                         表 b
    empid(主键) computerid     computerid(主键)  empid
      1            001            001   
      2            003            002
      3            002            003
      4            004            004
      

  3.   

    update b
    set empid=(
        select empid
        from a
        where a.computerid=b.computerid)
      

  4.   

    发贴格式乱了
      表 a 表 b
    empid computerid   
      1     001  
      2     003   
      3     002  
      4     004 
    computerid(主键) empid
      001   
      002
      003
      004
      

  5.   

    update b 
    set empid=(select empid from a where a.computerid=b.computerid)
    where exists(select 1 from a where a.computerid=b.computerid)
      

  6.   

    执行:
    update b
    set empid=(
      select empid
      from a
      where a.computerid=b.computerid) 
    好像是一直在循环,结束不了!!!!!!!
    zhuomingwang
    正解!!!!!