Subject Re: [firebird-support] Re: Multiple table update question
Author Aage Johansen
Daniel Jimenez wrote:

>> > However, I have a question regarding the sql > >>UPDATE
>>table1 T1 >>SET T1.field2 = (select T2.field2 FROM table2 T2
>> >> where T2.field1 = T1.field1) where
>> >>exists(select * from table2 T3
>> >> where T3.field1 = T2.field1)
>> >
>> > Is the where exist statement correct, or is there a typo?
>>Is this what you meant by "typo":
>>Can the last "T2.field1" have any relation to the "table2 T2"
>>in the first select? I don't think so.
>>Aage J.
> Hi Aage,
> No, I was refering to "where exists(select * from table2 T3
> where T2.field1 = T2.field1)"
> Which unless I have miss the point totally, which is very possible, you are
> doing a comparison on the same field of the same table.

I may not be reading the original query correctly, but (after some
reformatting) I think it looks like this:
update table1 T1
set T1.field2 = (select T2.field2
from table2 T2
where T2.field1 = T1.field1
where exists (select *
from table2 T3
where T3.field1 = T2.field1
and there's no "where T2.field1 = T2.field1" to be seen.

Still, I think the "where T3.field1 = T2.field1" makes no sense: at this
point, what is T2?
Unless I'm the one missing the point - not unlikely at all.

Aage J.