php-general | 2001032
Date: 03/19/01
- Next message: Chris Lee: "Re: [PHP] submission of 1..N variables"
- Previous message: Johnson, Kirk: "RE: [PHP] how do i get a variable type? - not that simple"
- In reply to: Jordan Elver: "[PHP] Query - Grouping Results"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
You can put this :
SELECT users.name AS name, user_logins.ip AS ip,
UNIX_TIMESTAMP(user_logins.time) AS time FROM users, user_logins WHERE
user_logins.user_id = users.id ORDER BY time ASC GROUP BY users.name
See the GROUP BY statement at mysql docs.
Mario H.C.T.
Jordan Elver wrote:
> Hi,
> I've got a table like:
>
> id user_id ip time
> 1 2 127.0.0.1 20010316105018
>
> Etc, etc.
>
> I do a join on the this table and the users table to get the coresponding
> username to user_id like this:
>
> SELECT users.name AS name, user_logins.ip AS ip,
> UNIX_TIMESTAMP(user_logins.time) AS time FROM users, user_logins WHERE
> user_logins.user_id = users.id ORDER BY time ASC
>
> How can I display the results grouped by username?
>
> So, I want to be able to display:
>
> Logins for John
>
> Thursday 10th
> Friday 12th
> Monday 23rd
>
> Logins for Bob
>
> Monday 1st
> Tuesday 2nd
> Saturday 31st
>
> Thanks for any help,
>
> Jord
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe <email protected>
> For additional commands, e-mail: php-db-help <email protected>
> To contact the list administrators, e-mail: php-list-admin <email protected>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Chris Lee: "Re: [PHP] submission of 1..N variables"
- Previous message: Johnson, Kirk: "RE: [PHP] how do i get a variable type? - not that simple"
- In reply to: Jordan Elver: "[PHP] Query - Grouping Results"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

