title: while loop with a multiple tableX union
body: <p>i want to know please how i can put
  union of table 2014 to 2017 only in loop in this query:</p>
  <p>select
  xxx,
  xxx,
  xxx,</p>
  <p>from (
  select
  colonne,
  colonne,
  from CA
  left join (<br />
  select
  xx,
  sum(xx) as xx,
  xx
  from (
  select
  sum(MONTANT) as MONTANT,
  CONCAT(NUM_SIN, CLE_SIN) as cle,
  EXER_SIN
  from fa
  where CD_TYP_CNT='PREV'
  group by NUM_SIN, CLE_SIN, EXER_SIN
  union
  select
  sum(MONTANT) as MONTANT,
  CONCAT(NUM_SIN, CLE_SIN) as cle,
  EXER_SIN
  from table2014
  where CD_TYP_CNT='PREV'
  group by NUM_SIN, CLE_SIN, EXER_SIN
  union
  select
  sum(MONTANT) as MONTANT,
  CONCAT(NUM_SIN, CLE_SIN) as cle,
  EXER_SIN
  from table2015
  where CD_TYP_CNT='PREV'
  group by NUM_SIN, CLE_SIN, EXER_SIN
  union
  select
  sum(MONTANT) as MONTANT,
  CONCAT(NUM_SIN, CLE_SIN) as cle,
  EXER_SIN
  from table2016
  where CD_TYP_CNT='PREV'
  group by NUM_SIN, CLE_SIN, EXER_SIN
  union<br />
  select
  sum(MONTANT) as MONTANT,
  CONCAT(NUM_SIN, CLE_SIN) as cle,
  EXER_SIN
  from table2017
  where CD_TYP_CNT='PREV'
  group by NUM_SIN, CLE_SIN, EXER_SIN ) as tab
  group by cle, EXER_SIN) as reglmt on reglmt.cle = CPM.dossiers</p>
  <pre><code>    left join (
          select 
              CONCAT(colonne, colonne) as cle, 
              
          from production
          group by colonne, colonne1, colonne3, colonne4) as xx on ptf_CPM.cle = CPM.dossiers
  group by xx, xx
  </code></pre>
  <p>) as xx
  where vérif &lt;&gt; 0</p>