title: SQL Server query - return null value if no match
body: <p>I'm running into a problem that I cannot figure out for some reason. I am trying to write a query that joins two tables, in which a match may not be found in a table. Such as:</p>
  
  <pre><code>SELECT 
      Table1.IDField, Table2.IDField
  FROM 
      Table1
  LEFT OUTER JOIN 
      Table2 ON Table1.PersonID = Table2.PersonID
  WHERE 
      (Table1.IDField = '12345')
      AND (Table2.Category = 'Foo')
  </code></pre>
  
  <p>If there is no match in <code>Table2</code>, it's not returning anything. However, I need it to just return a NULL for that column if there is no match and still return the value from <code>Table1</code>.</p>
  
  <p>I have changed up the <code>JOIN</code> with everything that I can think of, but to no avail. </p>
  
  <p><code>Table2.Category</code> can contain multiple other values, so doing a <code>OR IS NULL</code> type of deal won't work. </p>
  
  <p>So, if there is no match for <code>Table2.Category = 'Foo'</code>, I am still needing it to return:</p>
  
  <pre><code>Table1 | Table2
  ----------------
   12345 |  NULL
  </code></pre>
  
  <p>Any suggestions?</p>