Update one table from another w/o join statement (firebird)

寵の児 提交于 2019-12-02 09:18:43

Update your query as follow

update elements E set E.END_I = (select first 1 n.node_num from nodes N 
where (N.XI =E.X_I and N.YI = E.Y_I and N.ZI=E.Z_I) )
where exists (select 1 from nodes N where (N.XI =E.X_I and N.YI = E.Y_I and N.ZI=E.Z_I))

You should add first 1 because of firebird 2.1 doestn`t know that subquery return only one row.

Instead of trying to use UPDATE, use MERGE:

merge into elements E
  using node N
  on N.XI = E.X_I and N.YI = E.Y_I and N.ZI = E.Z_I
  when matched then
    update set E.END_I = N.node_num

Merge allows you to use another table, view or query as source of the data to update or insert into a table.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!