title: MySQL do INNER JOIN if specific value is 1
body: <p>I have this query:</p>
  
  <pre><code>SELECT 
      e.*, u.name AS event_creator_name 
  FROM `edu_events` e 
      LEFT JOIN `edu_users` u 
          ON u.user_id = e.event_creator 
      INNER JOIN `edu_event_participants` 
          ON participant_event = e.event_id &amp;&amp; participant_user = 1 
  WHERE 
      MONTH(e.event_date_start) = 6 
      AND YEAR(e.event_date_start) = 2013
  </code></pre>
  
  <p>It works perfect, however, I only want to do the INNER JOIN if the value: e.event_type equals 1. If not, it should ignore the INNER JOIN.</p>
  
  <p>I have tried for some time to figure it out, but the solutions seems difficult to implment for my proposes (as it is only for select/specific values).</p>
  
  <p>I'm thinking about something like:</p>
  
  <pre><code>SELECT 
      e.*, u.name AS event_creator_name 
  FROM `edu_events` e 
      LEFT JOIN `edu_users` u ON u.user_id = e.event_creator
  
  if(e.event_type == 1) {
      INNER JOIN `edu_event_participants` ON participant_event = e.event_id &amp;&amp; participant_user = 1 
  }
  
  WHERE MONTH(e.event_date_start) = 6 
  AND YEAR(e.event_date_start) = 2013
  </code></pre>