Click to See Complete Forum and Search --> : Simple little query...I think...


TygerTyger
02-13-2009, 02:30 PM
What I want to do is retrieve a list of all the original texts by user 1 and also the latest version of the text. The table is in the format below.


VARNAME TEXT USER TIME
test Testing 1 100000000
test Update 2 110000000
test Updated 3 120000000
test UPDATE 2 130000000


So one row would get the text "Testing" and "UPDATE". I'm sure it is simple but I can't quite get it.

I've managed the query for just the last text...


SELECT varname, text, time, MAX(time) as maxtime
FROM texts
WHERE user != 1
GROUP BY varname
HAVING time = maxtime


... but have failed to get it working as part of the larger query.

yamaharuss
02-15-2009, 08:45 PM
Why not simply

SELECT varname, text, time
FROM texts
WHERE user != 1
ORDER BY maxtime Desc