pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ross J. Reedstrom <reedstrm@rice.edu>
To: pgsql-sql@postgresql.org
Subject: Re: Help with a complex Update
Date: Mon, 5 Nov 2001 09:26:32 -0600
Message-ID: <20011105092632.A4292@rice.edu> (raw)
In-Reply-To: <9rv960$1des$1@news.tht.net>
References: <9rv960$1des$1@news.tht.net>

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



view thread (3+ messages)  latest in thread

Message-ID: <20011105092632.A4292@rice.edu>
Permalink:  ../20011105092632.A4292@rice.edu/
Also on:    postgresql.org/message-id/20011105092632.A4292@rice.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: reedstrm@rice.edu
  Subject: Re: Help with a complex Update
  In-Reply-To: <20011105092632.A4292@rice.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox