Subject Re: [ib-support] Update from select
Author Svein Erling Tysvaer
At 14:37 16.02.2003 +0000, you wrote:
>I have tried to use a
>update table1
> set field1 = table2.field,
> field2 = constantvalue,
> ...
>from table1, table2
> where ....
>
>but could not make it to work. Is this a valid construct in FB1 ?

No, not quite. You have to do something like

UPDATE table1
SET field1 = (SELECT field1 FROM table2 WHERE...), //This must be a
singleton select
field2 = <constant value>
WHERE EXISTS(SELECT 1 FROM table2 WHERE...)

WHERE EXISTS is necessary, otherwise table1.field1 will be set to NULL for
all records where there is no match in table2. If you want to update more
than one field from table2, you have to use more subselects.

Set