title: SQL Server: Compare nullable column in where clause
body: <p>I got a beginner's question about SQL server. I'm linking two tables with each other by setting a column of table A equal to a column in table B. Basically, my query looks like that:</p>
  
  <pre><code>SELECT A.nr, [...]
  FROM A, B
  WHERE A.id = B.id
  AND [...]
  </code></pre>
  
  <p>My problem is now that the id column in the table B also has some null values. So, if B.id is null, the whole row won't be shown because the condition isn't met. But if B.id is null, I just want A.nr also to be null instead of the whole row just not showing up. How can I do that? </p>
  
  <p>I thought about the following:</p>
  
  <pre><code>SELECT A.nr, [...]
  FROM A, B
  WHERE A.id = B.id OR B.id IS NULL
  AND [...]
  </code></pre>
  
  <p>but then the column is just mixed with all the possible B.id rows, no?</p>