Re: Help with a complex Update

From: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Help with a complex Update
Date: 2001-11-05 15:26:32
Message-ID: 20011105092632.A4292@rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jean-Michel POURE 2001-11-05 15:35:01 Re: [HACKERS] Porting Web application written in Oracle 8
Previous Message Janning Vygen 2001-11-05 14:58:26 Design Tool for postgresql