Board index » delphi » Update query using data from another table

Update query using data from another table

I need to do an update query using records from another table and I'm not
sure how.  This operation uses Paradox tables.  I need to do something like
this:

Update TABLE1 D1, TABLE2 D
set d1.field1 = D.field3
WHERE
(D1.fieldx = D.fieldx)
 AND (D1.fieldy = D.fieldy)

Can this be done?  I know the above doesn't work.

Thanks.

--

Don Gollahon
(dlgl...@theinter.com)

 

Re:Update query using data from another table


Something like:

UPDATE Table1 D1
SET D1.Field1 =
      (SELECT D2.Field1
       FROM Table2 D2
       WHERE D2.Field2 = D1.Field2)

=Bill

Re:Update query using data from another table


Hi Don!

On Thu, 26 Apr 2001 22:56:31 -0500, "Don Gollahon"

Quote
<dlgl...@theinter.com> wrote:
>I need to do an update query using records from another table and I'm not
>sure how.  This operation uses Paradox tables.  I need to do something like
>this:

>Update TABLE1 D1, TABLE2 D
>set d1.field1 = D.field3
>WHERE
>(D1.fieldx = D.fieldx)
> AND (D1.fieldy = D.fieldy)

try this ...

Update TABLE1
set field1 = (select field3 from TABLE2 WHERE (TABLE1.fieldx =
TABLE2.fieldx) AND (TABLE1.fieldy = TABLE2.fieldy))

tomi.

Other Threads