这是Informix更新的正确语法吗?
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')
Run Code Online (Sandbox Code Playgroud)
我得到了通用-201'发生语法错误'的消息,但我看不出有什么问题.
不幸的是,接受的答案会导致Informix Dynamic Server Version 11.50中出现语法错误.
这是避免语法错误的唯一方法:
update table1
set code = (
select 100
from table2 b, table3 c
where table1.key = c.key
and table1.no = b.no
and table1.key = c.key
and table1.code = 10
and b.tor = 'THE'
and table1.group = 4183
and table1.no in ('1111','1331','1345')
)
Run Code Online (Sandbox Code Playgroud)
顺便说一句,要获得Informix版本,请运行以下SQL:
select first 1 dbinfo("version", "full") from systables;
Run Code Online (Sandbox Code Playgroud)
你的语法错误是table1.code
set table1.code = 100
Run Code Online (Sandbox Code Playgroud)
将此更改为
set a.code = 100
Run Code Online (Sandbox Code Playgroud)
完整代码
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')
Run Code Online (Sandbox Code Playgroud)