update Informix table with joins

前端 未结 5 937
执笔经年
执笔经年 2021-01-17 14:35

Is this the correct syntax for an Informix update?

update table1
set table1.code = 100
from table1 a, table2 b, table3 c
where a.key = c.key
a.no = b.no
a.ke         


        
5条回答
  •  野的像风
    2021-01-17 14:58

    It depends on the version you are using. If you are using at least 11.50 the best solution would be:

    MERGE INTO table1 as t1
    USING table2 as t2
       ON t1.ID = t2.ID
    WHEN MATCHED THEN UPDATE set (t1.col1, t1.col2) = (t2.col1, t2.col2);
    

    The UPDATE - SET - FROM - Syntax was removed in versions greater than 11.50.

    If you are using an earlier version you can go with

    UPDATE t SET a = t2.a FROM t, t2 WHERE t.b = t2.b;
    

提交回复
热议问题