I have this tricky query that invloves GROUP BY.
Here's the query
mysql_query("select table1.session, table1.location, table1.ip, MAX(table1.time) as S, table2.user_id from track_session AS table1 INNER JOIN session_var AS table2 ON table1.session=table2.session group by table1.session order by S desc ");
The problem i'm having is that table1.location returns the first inserted row for each grouped table1.session.
What I need is the last inserted table1.location, so i'm able to display each users last know location.
Here are my table structure.
The track_session table has four colums:
session | ip | location | time
The session_var table has two columns:
session | user_id
The location column stores a string so i'm not able to use the aggregate function MAX.
Any help would be greatly appreciated.