Updating tuples based on max time

Поиск
Список
Период
Сортировка
От Michael
Тема Updating tuples based on max time
Дата
Msg-id 35A967A9.C89C18EC@wizard.ca
обсуждение исходный текст
Ответы Re: [ADMIN] Updating tuples based on max time
Список 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?


В списке pgsql-admin по дате отправления:

Предыдущее
От: newzcity@earthlink.net
Дата:
Сообщение: Your Own Adult Paysite!!!
Следующее
От: Alphonso Desselle
Дата:
Сообщение: Installation Question