Hi,
I have two tables, one containing account details and the second containing the account history. I'm trying to pull the date the account was last updated along with the account details in a single query;
SELECT
a.id, a.contact_name, a.username, a.status, b.timestamp
FROM
accounts a, history b
WHERE
(a.id = b.account_id)
GROUP BY username;
The only problem with this query is that it returns the timestamp of the first history record, rather than the last history record for that user. Is there a way to incorporate some sort of 'ORDER BY b.timestamp' prior to the 'GROUP BY' ?
thanks,
Pete
I have two tables, one containing account details and the second containing the account history. I'm trying to pull the date the account was last updated along with the account details in a single query;
SELECT
a.id, a.contact_name, a.username, a.status, b.timestamp
FROM
accounts a, history b
WHERE
(a.id = b.account_id)
GROUP BY username;
The only problem with this query is that it returns the timestamp of the first history record, rather than the last history record for that user. Is there a way to incorporate some sort of 'ORDER BY b.timestamp' prior to the 'GROUP BY' ?
thanks,
Pete