ifm1989 Posted April 19, 2008 Share Posted April 19, 2008 To dumb this down as much as possible, I have the following tables: wars, wars_participants, users, alliance_members, alliance I want to be able to search active wars. So the query would have to collect data in the following fashion: War #1 - - - - wars_participants (on war_id) -> alliance_members (on participant_user_id) -> alliance (on alliance_id) -> users (on participant_user_id) - - - - wars_participants (on war_id) -> alliance_members (on participant_user_id) -> alliance (on alliance_id) -> users (on participant_user_id) War #2 - - - - wars_participants (on war_id) -> alliance_members (on participant_user_id) -> alliance (on alliance_id) -> users (on participant_user_id) - - - - wars_participants (on war_id) -> alliance_members (on participant_user_id) -> alliance (on alliance_id) -> users (on participant_user_id) etc.etc. I'm able to get this far, but it only collects data for ONE participant. I need it to collect for all of them, so it can be searchable by alliance name and user name. $sql = "SELECT * FROM ".$prefix."wars LEFT JOIN `".$prefix."wars_participants` ON ".$prefix."wars.war_id=".$prefix."wars_participants.war_id LEFT JOIN `".$prefix."alliance_members` ON ".$prefix."alliance_members.alliance_user_id=".$prefix."wars_participants.participant_user_id LEFT JOIN `".$prefix."alliance` ON ".$prefix."alliance.alliance_id=".$prefix."alliance_members.alliance_id LEFT JOIN `".$prefix."users` ON ".$prefix."users.user_id=".$prefix."wars_participants.participant_user_id WHERE ".$prefix."alliance.name LIKE '%$search%' OR ".$prefix."users.user_name LIKE '%$search%' GROUP BY ".$prefix."users.user_id ORDER BY ".$SORT_CONFIG[$sort]." ".$DIR_CONFIG[$dir]." LIMIT $start,$results"; Is there some way I can have "sub querries" or something like that, so the results from one user is in an array inside the larger war array? Quote Link to comment Share on other sites More sharing options...
mwasif Posted April 20, 2008 Share Posted April 20, 2008 It would be better if you post only the SQL not PHP code. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 20, 2008 Share Posted April 20, 2008 Why would it only find one? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.