title: Print result from 2 queries in different columns of one table
body: <p>I am trying to output result from 2 queries in one table but no luck. Tried with <code>UNION</code> and with this template</p>
  <pre><code>SELECT x.a, y.b FROM (SELECT * from a) as x, (SELECT * FROM b) as y
  </code></pre>
  <p>with no luck. My queries are:</p>
  <pre><code>Select
      Sum('.MAIN_DB_PREFIX.'facturedet.qty) As qty_sum,
      '.MAIN_DB_PREFIX.'user.firstname,
      '.MAIN_DB_PREFIX.'user.lastname,
      '.MAIN_DB_PREFIX.'user.rowid,
      '.MAIN_DB_PREFIX.'facture.datef,
      '.MAIN_DB_PREFIX.'user.rowid
  From
      '.MAIN_DB_PREFIX.'facturedet 
  Inner Join
      '.MAIN_DB_PREFIX.'facture On '.MAIN_DB_PREFIX.'facturedet.fk_facture = '.MAIN_DB_PREFIX.'facture.rowid Inner Join
      '.MAIN_DB_PREFIX.'societe_commerciaux On '.MAIN_DB_PREFIX.'societe_commerciaux.fk_soc = '.MAIN_DB_PREFIX.'facture.fk_soc Inner Join
      '.MAIN_DB_PREFIX.'user On '.MAIN_DB_PREFIX.'societe_commerciaux.fk_user = '.MAIN_DB_PREFIX.'user.rowid
  Where
      &quot;.MAIN_DB_PREFIX.&quot;facture.datef Between Date_Format(Now(), '%Y-%m-01') And CurDate()
  GROUP BY
      '.MAIN_DB_PREFIX.'user.rowid
  ORDER BY 
      qty_sum DESC
  </code></pre>
  <p>and</p>
  <pre><code>Select
      Sum('.MAIN_DB_PREFIX.'facture.total) As total_sum,
      '.MAIN_DB_PREFIX.'user.firstname,
      '.MAIN_DB_PREFIX.'user.lastname,
      '.MAIN_DB_PREFIX.'user.rowid,
      '.MAIN_DB_PREFIX.'facture.datef,
      '.MAIN_DB_PREFIX.'user.rowid
  From
      '.MAIN_DB_PREFIX.'facture Inner Join
      '.MAIN_DB_PREFIX.'societe_commerciaux On '.MAIN_DB_PREFIX.'societe_commerciaux.fk_soc = '.MAIN_DB_PREFIX.'facture.fk_soc Inner Join
      '.MAIN_DB_PREFIX.'user On '.MAIN_DB_PREFIX.'societe_commerciaux.fk_user = '.MAIN_DB_PREFIX.'user.rowid
  Where
      &quot;.MAIN_DB_PREFIX.&quot;facture.datef Between Date_Format(Now(), '%Y-%m-01') And CurDate()
  GROUP BY
      '.MAIN_DB_PREFIX.'user.rowid
  ORDER BY
      total_sum DESC
  </code></pre>
  <p>With both <code>UNION</code> or combined query as mentioned above, I get blank result and no errors.</p>
  <p>Also, I cannot wrap the select in brackets and use an alias like <code>(query) a UNION (query2) b</code> as this also brings blank output.</p>
  <p>I can output first name + last name in column one of a table, sum_qty on second, some calculation is made based on the qty and it goes in the third column. In the fourth column, I need to output <code>total_sum</code></p>
  <p>Digged here like 20 threads and tried different solutions but no result.</p>
  <p>Full code: <a href="https://pastebin.com/bie0LXH9" rel="nofollow noreferrer">https://pastebin.com/bie0LXH9</a></p>