Subject RE: [firebird-support] Updating with inner join - noobie help needed
Author Alan McDonald
>
> Can someone please tell me what is wrong with this query.
>
> UPDATE VT_TR_TABLE
> SET VT_TR_TABLE.DISTRI = VT_TR_CABLE_TABLE.CA FROM VT_TR_TABLE INNER
> JOIN VT_TR_CABLE_TABLE ON
> VT_TR_TABLE.MASTER_KEY = VT_TR_CABLE_TABLE.MASTER_KEY;
>
> When I try to run it it gives the following error.
>
> Token unknown FROM
>
> The query is supposed to update DISTRI to CA where the two master
> keys match.
>
> Thanks for your help
> Lin
>

use barckets ans the SELECT key word

> UPDATE VT_TR_TABLE
> SET VT_TR_TABLE.DISTRI = (select VT_TR_CABLE_TABLE.CA FROM VT_TR_TABLE
INNER
> JOIN VT_TR_CABLE_TABLE ON
> VT_TR_TABLE.MASTER_KEY = VT_TR_CABLE_TABLE.MASTER_KEY);

you may need to control the number of records updated though and watch for
duplicates.. SELECT FIRST 1 may be required also.
Alan