title: Query with multi tables
body: <p>I have four tables:</p>
  
  <ul>
  <li>characters</li>
  <li>arena_team</li>
  <li>arena_table_member</li>
  <li>arena_team_stats.</li>
  </ul>
  
  <p>characters table has guid, name</p>
  
  <p>arena_team table has arenateamid, name, type</p>
  
  <p>arena_table_member table has guid(this is the same as in characters table), arenateamid</p>
  
  <p>arena_team_stats table has arenateamid, rating, wins, wins2, played</p>
  
  <p>How do I get the list of arena teams where character is? I tried:</p>
  
  <pre><code>$result=mysql_query("SELECT 
            characters.guid
             , characters.name
             , arena_team.arenateamid
             , arena_team.name
             , arena_team_stats.rating
             , arena_team_stats.wins
             , arena_team_stats.wins2
             , arena_team_stats.played
             , arena_team.type 
     FROM characters
             , arena_team_stats
             , arena_team 
      WHERE characters.name LIKE '%$q%' 
      AND arena_team.arenateamid = arena_team_stats.arenateamid 
      ORDER BY arena_team_stats.rating DESC") 
  or die(mysql_error());
  </code></pre>
  
  <p>but it returns all arena teams which are in arena_team table.</p>