Updating tuples based on max time

From: Michael <wwwadmin(at)wizard(dot)ca>
To: pgsql-admin <pgsql-admin(at)postgreSQL(dot)org>
Subject: Updating tuples based on max time
Date: 1998-07-13 01:49:30
Message-ID: 35A967A9.C89C18EC@wizard.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I keep crashing my backend doing the following
UPDATE logins SET
logoff_time='now'
WHERE
login_time=max(login_time)
AND
account_name='tempuser'
;

login_time is type 'datetime'

As a side note, I used this method because the following didn't work
UPDATE logins SET
logoff_time='now'
WHERE
id=(SELECT DISTINCT id FROM logins
WHERE
login_time IS NOT NULL
AND
account_name='tempuser'
)
;

Point is, what is the best method to update a record based on it's
datetime being the most recent?

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Alphonso Desselle 1998-07-13 14:36:55 Installation Question
Previous Message newzcity 1998-07-12 20:22:48 Your Own Adult Paysite!!!