日期:2014-05-18  浏览次数:20526 次

一个关于嵌套sql语句的问题,update语句
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语句怎么写啊?我那样写出错。谢谢!

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


------解决方案--------------------
你两表之间没有根据就没有建立联系,当然不能那要写了

update ASSET set coin=(select cost from HUMANSOURCE where hsId=7)
------解决方案--------------------
ql = "update ASSET a set a.coin=(select cost from HUMANSOURCE where b.hsId=7)