title: If statement within an inner join
body: <p>Is there a way to have an if statement determine whether a join is necessary or not?</p>
  
  <p>I need this because there are multiple foreign keys in the data I querying. if any of the foreign keys are null I need to change the SQL statement. I would like to write one statement that can be aware of any null values.</p>
  
  <p>This is what I would like to do...</p>
  
  <pre><code>select a.*,b.* from table1 a inner join table2 b on a.id = b.id
  if a.InspectorID is not null
  {inner join table3 c on a.InspectionID = c.id}
  else do nothing...
  </code></pre>