|
查看: 1418|回复: 2
|
请教SQL update Statement
[复制链接]
|
|
|
小弟试了很多次都不成功, 希望好心人能帮帮小弟
小弟想要 update report table from master table, 可是遇到了 error.
例子如下:
Report Table
| Serial | Title | Number | | Serial1 | Man | | | Serial2 | Woman | |
Master Table
| Serial | Number | | Serial1 | 3344 | | Serial2 | 5566 |
小弟的 Statement :
Update report set number = (select distinct number from Master where where serial in (select serial from report where report.serial = master.serial and master.number is not null))
可是却得到 error : -
:"Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."
经过google发现是因为 subquery return more than 1 value, which is 3344 and 5566. 如果两个都是3344或5566就没问题。
请问各位大大有什statement是可以一次过update multiple row (from table) with different values的吗?
先谢谢 了啊~
|
|
|
|
|
|
|
|
|
|
|
发表于 17-4-2010 12:14 PM
|
显示全部楼层
|
Update Report Set Number = (Select Number From Master Where Report.Serial = Master.Serial) |
|
|
|
|
|
|
|
|
|
|
发表于 17-4-2010 07:48 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|