Jump to content

PHP mySQL query question - JOIN


jawbreaker

Recommended Posts

Lets say I have two tables

NameID  Name
-------------------
1        Joe
2        Steve
3        Marty
4        Doug
-------------------


ID  NameID  Last LogIn
-------------------------
1  1        2006-01-01
2  1        2006-01-02
3  2        2006-01-02
4  3        2006-01-03
5  4        2006-01-03
6  4        2006-01-04
7  1        2006-01-04
8  2        2006-01-04
-------------------------


I have joined the tables (on name ID) and now I want to add to the sql statement so that it lists each of the peoples last login and only the last login. I have tried to use GROUP BY but it only gives me the first login and not the last login.

I need the output to look like the following

Joe 2006-01-04
Steve 2006-01-04
Marty 2006-01-03
Doug 2006-01-04

Link to comment
https://forums.phpfreaks.com/topic/33362-php-mysql-query-question-join/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.