一个部门表,一个人员表,部门表其中有一个字段为管理人员,存放的是人员表中的人员代码(有多个代码),人员表中有人员代码)和人员名称两个段,求一个查询语句能将部门表中的管理人员代码替换成人员表中的人员名称。谢谢了。

解决方案 »

  1.   

    update department t1 set employeeID=(select employeeName from Employee t2 where t1.employeeID=t2.employeeID)
    不知道是不是要这个?
    还是需要查询语句?
    select t1.departname,t2.employeeName as employeeID,... from department t1 left join Employee t2
    on t1.employeeID=t2.employeeID
      

  2.   

    要查询语句
    表A 
    a(代码)        b         c 
    123、456        湖北            仙桃 
    表B 
    a(代码)            b(姓名) 
    123                张三 
    456         李四 求一查询语句将表A中的a字段的代码替换成对应的B表中的姓名(显示结果如下)。 张三、李四   湖北     仙桃