Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fA5Gv6q56405 for ; Mon, 5 Nov 2001 11:57:06 -0500 (EST) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.7) with HTTP id 498968; Mon, 05 Nov 2001 08:57:10 -0800 From: "Josh Berkus" Subject: Re: Help with a complex Update To: o2@trustcommerce.com, pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.4.7 Date: Mon, 05 Nov 2001 08:57:10 -0800 Message-ID: In-Reply-To: <9rv960$1des$1@news.tht.net> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200111/60 X-Sequence-Number: 5444 Orion, > update user_info set first_action = (select min(action_timestamp) > from > action_info where user_id = ?? current user id ??); Close. You need to use a subselect in the FROM clause: UPDATE user_info SET first_action = min_action FROM (select user_id, min(action_timestamp) as min_action FROM action_info WHERE user_id = $user_variable GROUP BY user_id) ma WHERE user_info.user_id = ma.user_id; -Josh ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco