Subject | Re: [ib-support] Update from select |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2003-02-17T08:45:06Z |
At 14:37 16.02.2003 +0000, you wrote:
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
>I have tried to use aNo, not quite. You have to do something like
>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 ?
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