SQL Design Help (self join, sorta)
Posted: Thu Jun 10, 2010 12:34 am
I have a table that looks like this (people that play on my game servers):
id|name|ip|guid
And I have a search page, that basically does this:
Now, that will let me search by either name, ip, or guid (guid is a unique number to each player per server, and I have 8 servers). Now we know IP addresses tend to change, and players tend to play under a different name on occasion. I would like the search to be able to search other records that match the name, ip or guid from the first query. Is there a way to do that with SQL? So like a search for a player name, and not only get all the records that are LIKE that name, but also all the players with the same IP or GUID. Make sense?
id|name|ip|guid
And I have a search page, that basically does this:
Code: Select all
$sql = "SELECT id, name, INET_NTOA(ip) AS ip, guid FROM 1up_people WHERE (name LIKE \"%$query%\" OR INET_NTOA(ip) LIKE \"%$query%\" OR guid LIKE \"%$query%\")";