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:
  1. $query="SELECT a.user_id, a.access_date FROM superlog a
  2. WHERE a.access_date = (SELECT MAX(b.access_date)
  3.             FROM superlog b
  4.             WHERE a.user_id=b.user_id)
  5. AND ip = CONVERT( _utf8 '10.10.10.10' USING latin1 )
  6. COLLATE latin1_swedish_ci;