Portal Home > Knowledgebase > Articles Database > Mysql query


Mysql query




Posted by dataspiller, 10-14-2012, 07:22 PM
Not sure what to call this - I have a mysql database with the following structure: Table records the player ID, IP address and the date that IP was last used. if the player ID comes in on a different IP, then a new record is created. Goal of the database is to be able to see what IP's a player comes in under - and the reverse, see all players that come in under a given IP. I want to create an index page that will display this information and I was wondering if there is a way to properly group the information via a single query so that with the one mysql request I can get a list of all players and their respective IP's and vice versa. Only way I can think of to do it now would be a series of queries: 1st - get list of player_id's 2nd - loop through each player_id, recovering all IP's for that player ID 3rd - retrieve list of IP's 4th - loop through IP's recovering players for that IP Thanks

Posted by foobic, 10-14-2012, 08:45 PM
It sounds like you want two queries using different GROUP BYs. eg. and Given that both are pulling all records from the table you might want to limit them (eg. to recent dates) or clean out old records regularly. You'll probably also want indexes on the two columns you're using in GROUP BY (but run EXPLAIN query with your data to be sure).

Posted by dataspiller, 10-15-2012, 04:22 PM
Thank you very much Seth



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read


Language:

LoadingRetrieving latest tweet...

Back to Top Copyright © 2018 DC International LLC. - All Rights Reserved.