title: SQL - How to do an IF/ELSE in JOIN conditions
body: <p>I know how to perform an IF/ELSE in the join conditions, but is there a way I can use a different evaluation of the field altogether based on the ELSE?</p>
  
  <pre><code>SELECT o.id, s.id
  FROM orders o
  RIGHT JOIN subjects s ON s.name = 'Blah'
                       AND s.group_id = IF(o.service = 'Law Services', 2, ????)
  </code></pre>
  
  <p>In the above, I don't know what to put at <code>????</code></p>
  
  <p>What I want to say is (pseudo code):</p>
  
  <pre><code>IF o.service = 'Law Services'
  
      JOIN subjects s ON s.name = 'Blah' AND s.group_id = 2
  
  ELSE
  
      JOIN subjects s ON s.name = 'Blah'
  </code></pre>
  
  <p>Basically I only want to add the JOIN condition if <code>s.group_id = 2</code>.</p>