Subject | Re: subselect in subselect problem? |
---|---|
Author | Svein Erling |
Post date | 2004-03-23T10:49:17Z |
I don't know whether it is an error or not, but the first thing to do
is to eliminate all sources of potential errors. So try aliasing your
tables:
for select id,something from wtreestore into :id, :something do
begin
update demo d1 set d1.something =
(select d2.something from demo d2
where d2.id = (select max(d3.id) from demo d3
where d3.id < :id))
where d1.id = :id;
end
(I guess that in your where clauses d2.id could be considered d1.id
and that d3.id could be considered d1.id or d2.id by the engine when
omitting the aliases)
If it is an error, I would never have discovered nor noticed it in
this list since I generally use NOT EXISTS rather than = max.
HTH,
Set
is to eliminate all sources of potential errors. So try aliasing your
tables:
for select id,something from wtreestore into :id, :something do
begin
update demo d1 set d1.something =
(select d2.something from demo d2
where d2.id = (select max(d3.id) from demo d3
where d3.id < :id))
where d1.id = :id;
end
(I guess that in your where clauses d2.id could be considered d1.id
and that d3.id could be considered d1.id or d2.id by the engine when
omitting the aliases)
If it is an error, I would never have discovered nor noticed it in
this list since I generally use NOT EXISTS rather than = max.
HTH,
Set
--- In firebird-support@yahoogroups.com, "johnsparrowuk" wrote:
> Is this a known bug?
>
> for select id,something from wtreestore into :id, :something do
> begin
> update demo set something =
> (select something from demo
> where id = (select max(id) from demo where id < :id))
> where id = :id;
> end