有表一aa:(a,b,c)三列,
表二bb:  (aa,b,cc)三列.想修改aa表中的a列,须根据bb表中的cc列,这样的修改这么做呢.谢谢.

解决方案 »

  1.   

    update aa set a=(select cc from bb where aa.b=bb.b ...)
      

  2.   

    update aa set a=(select cc from bb where aa.b=bb.b )
    where exists (select 0 from bb where bb.b=aa.b)
      

  3.   

    aa和bb表是用什么字段关联呢,如果是用b,那就是一楼所说的咯:update aa set a=(select cc from bb where aa.b=bb.b )
      

  4.   

    不是,直接把aa表中的c列修改成bb表中的cc列值,比如cc列的值为"汽车" ,c列应该为'109'是这样的,请那位帮忙.谢谢.
      

  5.   

    update echinacard.air_merchant k
    set  k.merchant_type = (select trim(merchant_type) from echinacard.test_merchant g where g.merchant_id = k.merchant_id and g.merchant_type = '103')
    这句话多吗,为何加了条件修改,可把全部的数据都修改了啊
      

  6.   

    merchant_id merchant_name             merchant_type merchant_big_type
    10001774 宁波中国国际旅行社家乐门市部         104
    10001940 车奴汽车美容护理店                  104
    10001879 龙耀迪汽车租赁服务有限公司         104
    10002060 港中旅国贸旅行社有限公司         104
    10001880 龙耀迪汽车租赁服务有限公司         104
    这是表air_merchant
    merchant_id mer_big_type mer_name
    10001774    104          其他
    10001940    104          其他
    10001879    104          其他
    10002060    104          其他
    这是表test_merchant
    type_id type_name type_big
    108 汽车 104
    109 手机 104
    110 其他 104
    这是表air_merchant_type 表air_merchant中merchant_id与test_merchant中的merchant_id对应,test_merchant中merchant_big_type与air_merchant_type表中type_big对应.mer_name与type_name对应.我想经过这三张表修改air_merchant表中merchant_type 列.merchant_type列的值就是对应air_merchant_type表中type_id列.请问怎么做呢
      

  7.   

    update air_merchant a set merchant_type=(select b.type_id 
    from air_merchant_type b ,test_merchant c
    where  a.merchant_id=c.merchant_id and b.type_big=c.mer_big_type and b.type_name=c.mer_name)
      

  8.   

    update from  air_merchant A set merchant_type =(select c.type_id from  air_merchant B,air_merchant_type C where A.merchant_id=B.merchant_id and  B.mer_big_type=C.type_big and B.mer_name =C.type_name )