How do I do this update?

From: Allan Marcus <allan_at_est.lanl.gov>
Date: 1995/04/04
Message-ID: <allan.1147415500D_at_newshost.lanl.gov>#1/1


I could use some help with an update statement. I have two tables (A and B). I want to update field1 in table A with the value of field1 in table B. I want to join tables A and B with a field in each table (field2). Here's what I have so far, but this takes forever to run (Table A has 1700 rows and table B has 40000 rows):

Update A
set A.field1 = (select B.field1

                from B
                where a.field2 = b.field2)
where A.field2 in (select b.field2 
                    from B
                    where a.field2 = b.field2)

In sybase this update would be easy:

Update A
set a.field1 = b.field1
from B
where a.field2 = b.field2

Is there a better way?

Thanks,

Allan Marcus
"My opinions are my own, I think..."

AppleLink: Allan.Marcus
CIS: 76666,2113
InterNet: allan_at_apple.com (not affiliated with Apple Computer) eWorld or NewtonMail: Allan.M
Day Job email: allan_marcus_at_lanl.gov
Day Job Voice: 505-665-1828


Received on Tue Apr 04 1995 - 00:00:00 CEST

Original text of this message