title: How to make MySQL DISTINCT work with multiple columns using table join?
body: <p>How can I made the query below select only one record? Each game has two records (one record for each team). If there are nine (9) games there would be eighteen (18) records. I want to select only one record, not both records, for each game.</p>
  
  <p>If I use DISTINCT with only one column (game_id_2) it works fine or returns only nine records. However, if I try to add more columns the DISTINCT directive no longer works.</p>
  
  <pre><code>SELECT DISTINCT
  B.game_id_2,
  B.GmeYear,
  B.GmeMonth,
  B.GmeDay,
  B.GmeDate,
  B.GmeTime,
  B.GmeOrd,
  B.Home,
  B.DivPlay,
  L.Instit,
  FROM BsbGme B LEFT JOIN LeagueTeam L
  ON B.team_id = L.team_id
  WHERE B.NonD1=''
  AND B.team_id IN ($participant_str)
  AND B.GmeMonth = $GameMonth
  AND B.GmeDay = $GameDay
  ORDER BY B.game_id_2 ASC
  </code></pre>
  
  <p>According to w3schools dot come the DISTINCT directive is supposed to work with multiple columns. But it's not working with multiple columns in my example.</p>
  
  <p><strong>w3schools example:</strong></p>
  
  <p>SQL SELECT DISTINCT Syntax
  SELECT DISTINCT <em>column_name,column_name</em>
  FROM <em>table_name</em>;</p>
  
  <p><a href="http://www.w3schools.com/sql/sql_distinct.asp" rel="nofollow">http://www.w3schools.com/sql/sql_distinct.asp</a></p>
  
  <p>I have looked at several of the other answers to this same question on StackOverflow but I can't get any of them to work.</p>
  
  <p>Thank you in advance.</p>