Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5182D4759C6 for ; Fri, 23 Aug 2002 15:16:46 -0400 (EDT) Received: from mta5.snet.net (mta5.snet.net [204.60.203.77]) by postgresql.org (Postfix) with ESMTP id 900E34759C3 for ; Fri, 23 Aug 2002 15:16:45 -0400 (EDT) Received: from pop.snet.net ([204.60.203.73]) by mta5.snet.net (8.12.3/8.12.3/SNET-mx-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id g7NJDnt0015130 for ; Fri, 23 Aug 2002 15:13:49 -0400 (EDT) X-Originating-IP: [64.252.95.167] X-SBCIS-MTA: [pop.snet.net] Received: from [192.168.1.83] (167.95.252.64.snet.net [64.252.95.167]) by pop.snet.net (8.12.3/8.12.3/SNET-pop-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id g7NJGhT0023798 for ; Fri, 23 Aug 2002 15:16:43 -0400 (EDT) Subject: question on UPDATE TABLE From: Wei Weng To: pgsql-sql@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 23 Aug 2002 15:16:45 -0400 Message-Id: <1030130205.29121.8.camel@Monet> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/331 X-Sequence-Number: 9177 I have this query UPDATE ONLY ContentSummaries SET AccessID = '685d96de-1d09-11b2-beec-0001031d54ce' FROM Categories AS cat, ContentTypes AS ct, ContentSummaries AS cs LEFT OUTER JOIN Publishers AS pb ON (pb.PublisherID = cs.PublisherID) WHERE cs.CreationDate IS NOT NULL AND cat.CategoryID = cs.CategoryID AND ct.ContentTypeID = cs.ContentTypeID AND cat.CategoryID = '391b11d0-1d09-11b2-a312-0001031d54ce' Basically, I want to update contentsummaries table when the contentid (primary key of contentsummaries table) satisfies certain constraints. And here is the result of doing a select on the contentsummaries table with those constraints: mydatabase => select contentid from Categories AS cat, ContentTypes AS ct, ContentSummaries AS cs LEFT OUTER JOIN Publishers AS pb ON (pb.PublisherID = cs.PublisherID) WHERE cs.CreationDate IS NOT NULL AND cat.CategoryID = cs.CategoryID AND ct.ContentTypeID = cs.ContentTypeID AND cat.CategoryID = '391b11d0-1d09-11b2-a312-0001031d54ce' ; contentid -------------------------------------- 3cbda8c0-1d09-11b2-9851-0001031d54ce 3ca53e3e-1d09-11b2-9851-0001031d54ce 3c8b50c8-1d09-11b2-83cc-0001031d54ce 3c72e628-1d09-11b2-83cc-0001031d54ce 3c590226-1d09-11b2-83cc-0001031d54ce (5 rows) So I think, based on the documentation on the update table, I should then be able to update only those 5 rows (listed above) with my UPDATE query. But the UPDATE query updated all rows in contentsummaries table. mydatabase => UPDATE ONLY ContentSummaries SET AccessID = '685d96de-1d09-11b2-beec-0001031d54ce' FROM Categories AS cat, ContentTypes AS ct, ContentSummaries AS cs LEFT OUTER JOIN Publishers AS pb ON (pb.PublisherID = cs.PublisherID) WHERE cs.CreationDate IS NOT NULL AND cat.CategoryID = cs.CategoryID AND ct.ContentTypeID = cs.ContentTypeID AND cat.CategoryID = '391b11d0-1d09-11b2-a312-0001031d54ce' ; UPDATE 775 Did I do something wrong somewhere in my query? Or is it not do-able in current Postgresql? I am using Postgresql 7.2.1 (For redhat 7.3) Thanks in advance. -- Wei Weng Network Software Engineer KenCast Inc.