表1:(customer)两个字段:oper_id ,oper_name
表2:(man)两个字段:oper_id,oper_name
表1的oper_id对应表2的oper_id,我现在要在表1的oper_name,加入相应的(oper_name)值,用sql语句怎么实现

解决方案 »

  1.   

    select cus.oper_name || man.oper_name from customer cus, man where man.oper_id = cus.oper_id
      

  2.   

    select a.id,b.name from tgablea a ,tableb b where a.id=b.id
      

  3.   

    insert into man(oper_name) select oper_name from [customer]
      

  4.   

    update man set man.oper_name=customer.oper_name ;
    where man.oper_name=customer.oper_name
      

  5.   

    表1以前只有一个oper_id字段,现在我加了一个oper_name字段,我该怎样更新?这个意思
      

  6.   

    update man set man.oper_name=customer.oper_name ;
    where man.oper_name=customer.oper_name
    这样就好了,揭帖吧。
      

  7.   

    楼上的,我按你写的做不行啊,1,是通可oper_id关联的,
    2,怎么还有一个;号.
      

  8.   

    楼主是想把表一的oper-name字段更新为表二的所有和表一oper-id字段相同的oper-name吧
    我建议楼主用游标写:
    declare @id    varchar(20)
    declare @name  varchar(20)
    declare my_cur cursor for 
    select oper_id,opre_name from man
    as 
    fetch my_cur from my_cur to @id,@name
     while (@@fetch_status=0)
      begin
         update customer
           set oper_name=@name
           where oper_id=@id
        fetch my_cur from my_vur to @id,@name
      end
    close my_cur
    deallocate my_cur
    语法可能有错的,我记的不是很清楚了
      

  9.   

    Update man  set oper_name=select oper_name from customer
    where Man.oper_Id=Customer.OPer_ID
      

  10.   

    updae一次好象只能更新一条记录!!