May 2006


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:
  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;

MySQL Examples08 May 2006 10:43 am
MySQL Examples08 May 2006 10:42 am
MySQL Examples08 May 2006 10:42 am
MySQL Examples08 May 2006 10:40 am

Next Page »


WoW Gold - Free Animated Greetings - Wordpress Themes - Life Blogging - Windsurfing Video
X10 Home Security|Dakar's Photos
Listed on BlogShares