I have a group of records all with the same data except the timestamp (Yeah, not my design)
Example:
record_id, user, tmstmp
1, myself, 2006-11-15 09:56:14.325882-05
1, myself, 2006-11-15 09:56:19.051823-05
1, myself, 2006-11-15 11:23:30.581366-05
etc...
Now I would like to UPDATE the record with the latest timestamp. Here is what I’m trying with no luck yet:
UPDATE tbl
SET user = 'TESTING'
WHERE record_id = 1
ORDER BY tmstmp DESC
LIMIT 1
The ORDER BY throws the syntax error.
I think it should be a AND condition but not seeing how. Any thoughts?
PostgreSQL is my db.
UPDATE tbl
SET user = 'TESTING'
WHERE record_id = 1
AND tms_tmp in
(select max(tms_tmp) from tbl where record_id = 1)