【发布时间】:2014-01-24 12:13:09
【问题描述】:
我需要从表中选择一个employee_id
select emp_id
from employee emp, temp_data td where lower(td.supervisor_name) like lower(emp.last_name||emp.firstname)
并将其插入到同一张表的字段中
update emp set emp.supervisor_id = **The value returned from the previous query**
from employee as emp
Inner join temp_table as td
on td.emp_id = emp.emp_id
有什么方法可以实现吗?问题是我在更新语句中设置它时引用了同一个表的另一个字段。如果有任何其他路线我可以去,请告诉我...我在 Informix 中做。
【问题讨论】:
-
将查询放在更新语句中 Equlas to Symbol 之后
-
感谢您的回复...它需要永远并给我以下错误... 18:18:39 [更新 - 0 行,0.000 秒] [错误代码:- 79716,SQL 状态:IX000] 系统或内部错误 java.net.SocketTimeoutException:读取超时 ... 1 条语句执行,0 行受影响,执行/获取时间:0.000/0.000 秒 [0 成功, 0 个警告,1 个错误] 我知道其中有问题,因为这就像两次声明相同的表。如果您认为它会起作用,请您为我写下整个语句。谢谢
-
如果有这个问题,请勾选:stackoverflow.com/questions/19004605/… 帮助您解决问题。
-
您好 ceinmart,感谢您的回复。但是我已经在合并语句中使用了这个查询。我不确定在另一个合并语句中使用合并的效率如何。此外,它不仅仅是一个简单的分配 ON t1.ID = t2.ID... 它应该是 t1.id = select id from the table where last name matches... 有没有办法先获取值,将其存储在变量中然后更新?那会容易得多...