Using the IN predicate in an UPDATE... - Mailing list pgsql-sql

From Thomas Good
Subject Using the IN predicate in an UPDATE...
Date
Msg-id Pine.LNX.3.96.981014085503.5064A-100000@admin.nrnet.org
Whole thread Raw
In response to Re: [SQL] dilemma  (Herouth Maoz <herouth@oumail.openu.ac.il>)
Responses Re: Using the IN predicate in an UPDATE...  (Herouth Maoz <herouth@oumail.openu.ac.il>)
Re: [SQL] Using the IN predicate in an UPDATE...  (Leslie Mikesell <les@Mcs.Net>)
List pgsql-sql
Herouth,

This query takes 20 years (poetic licence invoked ;-).
Do you have a smarter way to accomplish this end:

UPDATE table1 SET id = 2
WHERE rec_num IN
 ( SELECT rec_num
   FROM table1
   WHERE id = 1
  );

This is an attempt to cleanup some user error...I have an old
foxpro db that uses a char str as an index and this index has no
check constraints (like, making the index unique...ouch.)
The new pg db is performing nicely, now that it's live...and
housing 12 years worth of data.  But I am saddled with quite a bit
of housekeeping - correcting anomalies that were part and parcel
of the original (foxpro) design.  Or absence thereof.

Thanks much!
Tom

    ---------- Sisters of Charity Medical Center ----------
                   Department of Psychiatry
                            ----
    Thomas Good                          <tomg@q8.nrnet.org>
    Coordinator, North Richmond C.M.H.C. Information Systems
    75 Vanderbilt Ave, Quarters 8        Phone: 718-354-5528
    Staten Island, NY   10304            Fax:   718-354-5056



pgsql-sql by date:

Previous
From: Herouth Maoz
Date:
Subject: Re: [SQL] correlative insertion
Next
From: Herouth Maoz
Date:
Subject: Re: Using the IN predicate in an UPDATE...