请教一个informix中的SQL查询!
下面查询在informix中运行出错:updatestatistics
set num=num+5
where id in (select id from statistics where num>10);
错误提示:Cannot modify table or view used in subquery statistics 这个是表?:shock: :shock: :shock: 原帖由 30donothing 于 2008-7-3 16:33 发表 http://bbs.chinaunix.net/images/common/back.gif
下面查询在informix中运行出错:
updatestatistics
set num=num+5
where id in (select id from statistics where num>10);
错误提示:Cannot modify table or view used in subquery
如果statistics是表的话,这样做也是不符合informix的语法的。 statistics是表名,暗夜星空说不符合informix的语法,怎么回事啊?请高手指点 informix是不是不支持子查询啊?
回复 #5 30donothing 的帖子
你这个是自表查询更新,可能导致死循环,这在informix中是禁止的。:em17: :em17:你可以考虑下使用临时表。 updatestatistics
set num=num+5
where num>10
将简单问题复杂化不是解决问题之道,ps:statistics最好不要用做表名,改个名字 原帖由 blackuhlan 于 2008-7-8 19:30 发表 http://bbs.chinaunix.net/images/common/back.gif
updatestatistics
set num=num+5
where num>10
将简单问题复杂化不是解决问题之道,ps:statistics最好不要用做表名,改个名字
你这么做可能改变了语义了吧。
idnum
1 5
1 11
按照原来的写法,应该这两条记录都会update,按照你的写法,只有第二条能得到更新。
实际上,由于informix不提供类似oracle的读一致性,因此,这个问题基本上只能用临时表来实现。
页:
[1]