I have a table for a list of people allowed in a building. Each resident is allowed to give 10 nonresidents access.
resident guest1 guest2 ... guest10
I want to search over all the guests, and then display the results in alphabetical order. Currently I have:
$result = mysql_query("SELECT * FROM residentlist WHERE guest1 LIKE 'searchquery' OR guest2 LIKE 'searchquery' ... OR guest10 LIKE 'searchquery'";
But I end up with extra guests that aren't like 'searchquery', so I need to do a bunch more if checks.
I'm new to mysql - am I missing something simple?
Also, I'm open to restructuring the table / adding tables if that's better.