title: MySQL: Joining a table on a field that could be NULL
body: <p>I have two tables (Releases and Formats) and a field that is linked to both of them - <code>bar_code</code>. The problem I am having is with this select statement:</p>
  
  <pre><code>SELECT
      Release.name,
      Release.default_upc,
      Artist.name,
      Artist.url_name,
      Format.*
  FROM
      releases AS Release,
      artists AS Artist,
      formats AS Format
  WHERE
      Release.id IN(20015, 2414) AND
      Artist.id = Release.artist_id AND
      Format.bar_code = Release.default_upc
  </code></pre>
  
  <p>The issue is that when <code>Release.default_upc = null</code>, no record will be returned. However, it is a valid behavior that <code>default_upc</code> can be null, and if it is the query should <em>not</em> attempt to look for a Format with <code>Format.bar_code = null</code> - instead just returning the other selected data.</p>
  
  <p>Not actually sure this is 100% possible in MySQL, but open to any advice.</p>