title: MySQL JOIN if either of the 2 tables meets condition
body: <pre><code>SELECT COALESCE(table2.value, table3.value) FROM table1
  JOIN table2 ON (table1.value = table2.value)
  JOIN table3 ON (table1.value = table3.value)
  </code></pre>
  
  <p><code>table1.value = table2.value</code> and <code>table1.value = table3.value</code> are mutually exclusive (at most one of them will be true).</p>
  
  <p>How do I make the join happen only if either <code>table1.value = table2.value</code> or <code>table1.value = table3.value</code> is true?</p>
  
  <p>Is this the only solution? (which is rather tedious)</p>
  
  <pre><code>SELECT table.value FROM table1
  JOIN 
  (SELECT COALESCE(table2.value, table3.value) FROM table1
   LEFT JOIN table2 ON (table1.value = table2.value)
   LEFT JOIN table3 ON (table1.value = table3.value)
  ) as table ON (table1.value = table.value)
  </code></pre>