Using the IN predicate in an UPDATE...

From: Thomas Good <tomg(at)admin(dot)nrnet(dot)org>
To: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
Cc: PostgreSQL List <pgsql-sql(at)postgreSQL(dot)org>
Subject: Using the IN predicate in an UPDATE...
Date: 1998-10-14 13:06:01
Message-ID: Pine.LNX.3.96.981014085503.5064A-100000@admin.nrnet.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)q8(dot)nrnet(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Herouth Maoz 1998-10-14 14:42:32 Re: Using the IN predicate in an UPDATE...
Previous Message Herouth Maoz 1998-10-14 09:49:23 Re: [SQL] correlative insertion