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

前端 未结 2 532
南笙
南笙 2021-01-28 03:19

I\'d like to update the columns in on table based on the values of another table, I use a slightly old version of Firebird 2.1 so it doesn\'t have support for the join statement

2条回答
  •  忘掉有多难
    2021-01-28 04:05

    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.

提交回复
热议问题