title: MySQL join different table on case
body: <p>I'm trying to join a different table depended on the value of a "task_type" column</p>
  
  <p>What is wrong with the syntax?
  Thanks.</p>
  
  <pre><code>SELECT t.*,s.task_name
      CASE
      WHEN t.task_type = 0 THEN
      LEFT JOIN scheduler_tasks s ON s.scheduler_task_id = t.task_id
      WHEN t.task_type = 1 THEN 
      LEFT JOIN invoice_tasks s ON s.uid = t.task_id 
      END 
      FROM task_timings t 
      WHERE t.account_id = ? AND t.start_date &gt;= DATE(?) AND t.start_date &lt;= DATE(?)
  </code></pre>