Received: from ece.rice.edu (ece.rice.edu [128.42.4.34]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fA5FQUq53286 for ; Mon, 5 Nov 2001 10:26:30 -0500 (EST) (envelope-from reedstrm@rice.edu) Received: from localhost (localhost [127.0.0.1]) by ece.rice.edu (Postfix) with ESMTP id 4274D68A57 for ; Mon, 5 Nov 2001 09:26:33 -0600 (CST) Received: from wallace.ece.rice.edu (wallace.ece.rice.edu [128.42.12.154]) by ece.rice.edu (Postfix) with ESMTP id 8894F68A17 for ; Mon, 5 Nov 2001 09:26:32 -0600 (CST) Received: from reedstrm by wallace.ece.rice.edu with local (Exim 3.22 #1 (Debian)) id 160ldw-00018Z-00 for ; Mon, 05 Nov 2001 09:26:32 -0600 Date: Mon, 5 Nov 2001 09:26:32 -0600 From: "Ross J. Reedstrom" To: pgsql-sql@postgresql.org Subject: Re: Help with a complex Update Message-ID: <20011105092632.A4292@rice.edu> Mail-Followup-To: "Ross J. Reedstrom" , pgsql-sql@postgresql.org References: <9rv960$1des$1@news.tht.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9rv960$1des$1@news.tht.net> User-Agent: Mutt/1.3.18i X-Virus-Scanned: by AMaViS snapshot-20010714 X-Archive-Number: 200111/53 X-Sequence-Number: 5437 On Fri, Nov 02, 2001 at 03:15:36PM -0800, Orion wrote: > I have a table of users and a table of user_actions. > I'd like to have a first_action column in the user table. > > How would I go about updating that info. > > I'd immagine it'd be something like this: > > update user_info set first_action = (select min(action_timestamp) from > action_info where user_id = ?? current user id ??); Guessing at your table schema, but I think you want: update user_info set first_action = min(action_timestamp) from action_info where action_info.user_id = user_id; Ross