title: Using CASE Statements in LEFT OUTER JOIN in SQL
body: <p>I've got a scenario where I want to switch on two different tables in an outer join. It goes something like this:-</p>
  
  <pre><code>         select mytable.id, 
                  yourtable.id
             from mytable
  left outer join (case
                      when mytable.id = 2 then table2 
                        yourtable on table1.id = table2.id
                      else
                        table3 yourtable on table1.id = table3.id
                   end)
  </code></pre>
  
  <p>...but it doesn't work. Any suggestions?</p>