Subject | Re: [firebird-support] Update with data FROM a table |
---|---|
Author | Magnus Titho |
Post date | 2005-08-25T14:58:07Z |
m_formigoni wrote:
update table1 t1
set t1.field1 = (select t2.field1 from table2 t2 where t1.id = t2.id),
t1.field2 = (select t2.field2 from table2 t2 where t1.id = t2.id)
This will either work or throw an error "multiple rows in singleton
select" if there is more than one matching record in table2.
--
Magnus
>I'm trying to do an update in a table using data from another table,You could try
>like this:
>
>update TABLE
> set FIELD1 = T2.FIELD1,
> FIELD2 = T2.FIELD2
> from TABLE2 T2
> where TABLE.ID = T2.ID
>
>
update table1 t1
set t1.field1 = (select t2.field1 from table2 t2 where t1.id = t2.id),
t1.field2 = (select t2.field2 from table2 t2 where t1.id = t2.id)
This will either work or throw an error "multiple rows in singleton
select" if there is more than one matching record in table2.
--
Magnus