title: How to get one row from a many to many relationship in mysql
body: <p><img src="https://i.stack.imgur.com/4tMqQ.png" alt="tables"></p>
  
  <pre><code>id name   (sources)
  -- ----
  1  first
  2  second
  
  source_id tag_id   (source_tags)
  --------- ------
  1         1
  1         2
  2         3
  
  source_id tag_id exception_value   (source_tag_exceptions)
  --------- ------ ---------------
  1         2      1
  1         1      2 
  
  id name   (tags)
  -- ----
  1  tag_one
  2  tag_two
  3  tag_three
  </code></pre>
  
  <p><a href="http://www.filedropper.com/4-29-15import_1" rel="nofollow noreferrer">sql import file</a><br/>
  <a href="http://sqlfiddle.com/#!9/f8630/1/0" rel="nofollow noreferrer">sqlfiddle</a></p>
  
  <p>I have a one to many relationship for sources and source tags. I'm looking to show the source_tag_exceptions.exception_value if there are any available. When I do a simple LEFT JOIN, I get one row for each source_tag. I understand why, but how do I show only one row for the source_tag_exceptions and still show all source rows? If there are multiple rows, I would prefer to see the value 1 over any others...</p>
  
  <p>This is the query I am using that returns multiple rows</p>
  
  <pre><code>SELECT sources.name, source_tag_exceptions.exception_value
  FROM sources
  LEFT JOIN source_tags ON source_tags.source_id = sources.id
  LEFT JOIN source_tag_exceptions ON source_tag_exceptions.source_id = sources.id AND source_tag_exceptions.tag_id = source_tags.tag_id
  </code></pre>
  
  <p>Current Results</p>
  
  <pre><code>name   exception_value
  ----   ---------------
  first  1
  first  2
  second NULL
  </code></pre>
  
  <p>Target Results</p>
  
  <pre><code>name   exception_value
  ----   ---------------
  first  1
  second NULL
  </code></pre>