Board index » delphi » Updating a table with a field from another table using Interbase

Updating a table with a field from another table using Interbase

Hi,

I need to update a field with the content of another field (from another
table). Using MS SQL Server 7.0, I can execute the follow statement:

UPDATE TABLE1 SET FIELD1 = TABLE2.FIELD1 FROM TABLE2 WHERE TABLE2.FIELD0 =
TABLE1.FIELD0

I have tried to execute something like this on IB 6.0, but it does not work.

How can I solve that???

Thanks

Giovani Marinho

 

Re:Updating a table with a field from another table using Interbase


Hi!

You have to set your SQL Statement like this:

UPDATE TABLE1 SET FIELD1 = (SELECT TABLE2.FIELD1 FROM TABLE2 WHERE
TABLE2.FIELD0 = TABLE1.FIELD0)

Then your request is executed.

"Giovani Marinho" <giov...@ngm.com.br> schrieb im Newsbeitrag
news:3a89424a_2@dnews...

Quote
> Hi,

> I need to update a field with the content of another field (from another
> table). Using MS SQL Server 7.0, I can execute the follow statement:

> UPDATE TABLE1 SET FIELD1 = TABLE2.FIELD1 FROM TABLE2 WHERE TABLE2.FIELD0 =
> TABLE1.FIELD0

> I have tried to execute something like this on IB 6.0, but it does not
work.

> How can I solve that???

> Thanks

> Giovani Marinho

Re:Updating a table with a field from another table using Interbase


Quote
Giovani Marinho wrote:

> I need to update a field with the content of another field (from another
> table). Using MS SQL Server 7.0, I can execute the follow statement:

> UPDATE TABLE1 SET FIELD1 = TABLE2.FIELD1 FROM TABLE2 WHERE TABLE2.FIELD0 =
> TABLE1.FIELD0

UPDATE TABLE1 T1
SET T1.FIELD1 =
  (SELECT
     T2.FIELD1
   FROM
     TABLE2 T2
   WHERE
     T2.FIELD0 = T1.FIELD0)

        Incidentally, this newsgroup is for discussing IBX.  A question like
this would be more appropriate in borland.public.interbase.general.

        HTH,

        -Craig

--
Craig Stuntz               Vertex Systems Corporation
Senior Developer           http://www.vertexsoftware.com

Delphi/InterBase weblog:   http://delphi.weblogs.com

Other Threads