Re: How do I do this update?

From: Steve Butler <sbut-is_at_seatimes.com>
Date: 1995/04/05
Message-ID: <Pine.SUN.3.91.950405100830.27399C-100000_at_seatimes>#1/1


On Tue, 4 Apr 1995, Allan Marcus wrote:
> 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)

Just put the ';' at the end and let it rip. I'm not sure why you added the following?

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

If there are rows in A where field2 is not in B then the update will change A.field2 to NULL. If you really want to leave those rows alone then use the first two lines of the above group of three. There is no need for the final where clause.

I think you have the database chasing almost a circle here. In fact, this looks like a corolated sub-query inside a corolated sub-query. They are going in opposite directions.

Hope this helps.

+----------------------------------------------------+
| Steve Butler          Voice:  206-464-2998         |
| The Seattle Times       Fax:  206-382-8898         |
| PO Box 70          Internet:  sbut-is_at_seatimes.com |
| Seattle, WA 98111    Packet:  KG7JE_at_N6EQZ.WA       |
+----------------------------------------------------+
All standard and non-standard disclaimers apply. All other sources are annonymous. Received on Wed Apr 05 1995 - 00:00:00 CEST

Original text of this message