title: MySQL - Conditional Join
body: <p>I have an MySQL that is working correctly:</p>
  
  <pre><code>SELECT
        tblprocedimento.idProcedimento,
        tblprocedimento.tituloProcedimento,
        tblprocedimento.tipoProximoS,
        tblprocedimento.numeroProximoS,
        tblprocedimento.tipoProximoN,
        tblprocedimento.numeroProximoN,
        ap1.nomeProximo AS nomeProximoS,
        ap2.nomeProximo AS nomeProximoN,
        tblauxtextoprocedimento.textoProcedimento,
        tblauxprocedimento.sTipificacao,
        tblNivel1.nivel1,
        tblNivel2.nivel2,
        tblNivel3.nivel3,
        tblNivel4.nivel4   
      FROM
      tblAuxTextoProcedimento
      LEFT JOIN 
      tblAuxProcedimento 
      ON 
      tblAuxTextoProcedimento.idTextoProcedimento = tblAuxProcedimento.sTextoProcedimento,
      tblNivel4 INNER JOIN (tblNivel3
      INNER JOIN (tblNivel2
      INNER JOIN (tblNivel1
      INNER JOIN tblAuxTipificacao
      ON tblNivel1.idNivel1 = tblAuxTipificacao.sNivel1)
      ON tblNivel2.idNivel2 = tblAuxTipificacao.sNivel2)
      ON tblNivel3.idNivel3 = tblAuxTipificacao.sNivel3)
      ON tblNivel4.idNivel4 = tblAuxTipificacao.sNivel4,
        tblprocedimento,
        tblauxproximo As ap1,
        tblauxproximo As ap2
      WHERE
        ap2.idProximo = tblprocedimento.sProxN AND
        ap1.idProximo = tblprocedimento.sProxS AND
        tblprocedimento.idProcedimento = 1 AND
        tblAuxProcedimento.sProcedimento = 1 AND
        tblAuxTipificacao.idTipificacao = 130
  </code></pre>
  
  <p>I would like to know If It's possible to only query <code>tblNivel1</code>, <code>tblNivel2</code>, <code>tblNivel3</code> and <code>tblNivel4</code> <code>IF tblAuxTipificacao.idTipificacao &lt;&gt; value</code> inside this query.</p>
  
  <p>What's the best practice to do so or should I rewrite the query.</p>