sql = "update ASSET a set a.coin=(select b.cost from HUMANSOURCE b where b.hsId=7)意思是 A 表 ASSET
       B 表 HUMANSOURCE把A表的coin字段设成从B表查找出来的值,sql语句怎么写啊?我那样写出错。谢谢!

解决方案 »

  1.   

    两表之间没有关系? 按 LZ 写法,子查询具有多值如何 update?
      

  2.   

    update ASSET set coin=(select b.cost from HUMANSOURCE b where b.hsId=7)
      

  3.   

    楼主确定select b.cost from HUMANSOURCE b where b.hsId=7查询出来的是唯一值吗?
      

  4.   

    如果是唯一值的话,sql语句是可以执行的。
      

  5.   

    sql = "update ASSET a set a.coin in (select b.cost from HUMANSOURCE b where b.hsId=7)
      

  6.   

    你两表之间没有根据就没有建立联系,当然不能那要写了update ASSET set coin=(select cost from HUMANSOURCE  where hsId=7)
      

  7.   

    update userInfo set userName=(select userName+'W' from userInfo where userID='10' and state='D')
    类似于这样吧?
      

  8.   

    ql = "update ASSET a set a.coin=(select cost from HUMANSOURCE  where b.hsId=7)
      

  9.   

    两个标的关系没有直接的对应关系,但是hsid找出来的值是唯一的,大概是这样的表ASSET:
    userId coin
    7      0
    8      11
    9      5HUMANSOURCE
    hsId userId cost
    7    7      11
    8    7      45
    9    8      67
    10   7      11另外有一个USERINFO表和这两张表对应,这里在HUMANSOURCE中根据hsid找出cost字段的值,再把这个值更新到ASSET对应的userid中的coin里,楼上的写法都有问题啊~
      

  10.   

    对了,ASSET中的USERID是唯一的