Source SQL in question:
update table1 set table1.code = 100 from table1 a, table2 b, table3 c where a.key = c.key a.no = b.no a.key = c.key a.code = 10 b.tor = 'THE' a.group = 4183 a.no in ('1111','1331','1345')
This unconditionally missing series of I-words. The decision also identifies the problem in the SET clause using table1
instead of its alias a
. It may be material; I cannot verify it (see discussion below). So, assuming the UPDATE join is accepted at all, the corrected SQL should read:
UPDATE table1 SET a.code = 100 FROM table1 a, table2 b, table3 c WHERE a.key = c.key AND a.no = b.no AND a.key = c.key AND a.code = 10 AND b.tor = 'THE' AND a.group = 4183 AND a.no IN ('1111','1331','1345')
This is the same as the accepted (syntactically corrected) answer. However, I am curious to know which version of Informix you are using that accepts FROM syntax (maybe XPS?). I am using IDS 11.70.FC2 (3 fix packs for the current version 11.70.FC5) on Mac OS X 10.7.4, and I cannot get UPDATE with FROM syntax to work. In addition, the IBM Informix 11.70 Information Center for UPDATE manual does not mention this. I am not sure if it will matter if you use ODBC or JDBC; it should not, but I am using ESQL / C, which sends SQL unchanged to the server.
The designation I tried ( +
is an invitation):
+ BEGIN; + CREATE TABLE a(a INTEGER NOT NULL, x CHAR(10) NOT NULL, y DATE NOT NULL); + INSERT INTO a(a, x, y) VALUES(1, 'obsoletely', '2012-04-01'); + INSERT INTO a(a, x, y) VALUES(2, 'absolutely', '2012-06-01'); + CREATE TABLE b(b INTEGER NOT NULL, p CHAR(10) NOT NULL, q DATE NOT NULL); + INSERT INTO b(b, p, q) VALUES(3, 'daemonic', '2012-07-01'); + SELECT * FROM a; 1|obsoletely|2012-04-01 2|absolutely|2012-06-01 + SELECT * FROM b; 3|daemonic|2012-07-01 + SELECT * FROM a, b WHERE aa < bb AND bp MATCHES '*a*e*'; 1|obsoletely|2012-04-01|3|daemonic|2012-07-01 2|absolutely|2012-06-01|3|daemonic|2012-07-01 + UPDATE a SET x = 'crumpet' FROM a, b WHERE aa < bb AND bp MATCHES '*a*e*'; SQL -201: A syntax error has occurred. SQLSTATE: 42000 at <<temp>>:23 + SELECT * FROM a; 1|obsoletely|2012-04-01 2|absolutely|2012-06-01 + ROLLBACK;