MySQL Examples31 May 2006 10:09 am
A quick query structure to retrive the last row entry to a logging table, in this case there can be multiple rows that would return the same id and date but I want only the very last so this query works well.
CODE:
-
$query="SELECT a.user_id, a.access_date FROM superlog a
-
WHERE a.access_date = (SELECT MAX(b.access_date)
-
FROM superlog b
-
WHERE a.user_id=b.user_id)
-
AND ip = CONVERT( _utf8 '10.10.10.10' USING latin1 )
-
COLLATE latin1_swedish_ci;