title: Is it possible to use a column from another join to create a condition in another join mysql
body: <p>I will edit so it will not be classified as a duplicate.</p>
  
  <p>I would like to use the XA.XA_REASON_CODE for a condition like statement to determine if I would use a condition or not.</p>
  
  <p>If the XA.XA_REASON_CODE is = <code>EH</code> then I won't use <code>AND HOLDFLAG != 'R'</code>. Else use <code>AND HOLDFLAG != 'R'</code> in the condition for my join.</p>
  
  <pre><code>SELECT
   I.DATERELEASED,
   XA .XA_REASON_CODE,
  FROM
      FEPC.EWHITEBOARD AS EWB
  LEFT JOIN FEPC.EWHITEBOARD_XA XA ON EWB.EWHITEBOARD_ID = XA .EWHITEBOARD_ID
  LEFT JOIN(
      SELECT
          DATERELEASED
      FROM
          HOURLY_FT_WIP.CACHE_IRAC_HOLD_LOTS
      WHERE
          LOTNUM IN(
              'SAKZ3A024B',
              'JS61DA009G'
          )
  if(XA.XA_REASON_CDOE = 'EH') THEN
      #nothing
  else then
  AND HOLDFLAG != 'R'
      )AS I ON I.LOTNUM = PRODUCTIONORDERID
  </code></pre>