title: SQL - Nested result instead of merge when left join
body: <p>I have a SQL LEFT JOIN like this:</p>
  <pre><code>var getEmail = req.body.email;
  
  const connection = require('../conig/db');
  let promise = await new Promise((resolve,reject)=&gt;{
      connection.query(&quot;SELECT users.id, users.account_id, users.email, accounts.id, accounts.company FROM users LEFT JOIN accounts ON accounts.id=users.account_id WHERE users.email = ?&quot;,[getEmail], function(err, rows) {
          if (err) {
              console.log(err);
              resolve();
          }
          console.log('rows:');
          console.log(rows);
          resolve();
      });
  });
  </code></pre>
  <p>The result merges the columns:</p>
  <pre><code>[{
      id: 1,
      account_id: '1',
      email: 'user01@domain',
      company: 'Company 01'
  }, {
      id: 3,
      account_id: '3',
      email: 'user02@domain',
      company: 'Company 02'
  }, {
      id: null,
      account_id: '',
      email: 'user03@domain',
      company: null
  }]
  </code></pre>
  <p>But what I would like to have is a nested result with the table name at first level like this:</p>
  <pre><code>[{
    users: {
      account_id: '1',
      email: &quot;user01@domain&quot;,
      id: 1
    },      
    accounts: {
      company: &quot;Company 01&quot;,
      id: 1
    }
  }, {
    users: {
      account_id: '3',
      email: &quot;user02@domain&quot;,
      id: 2
    },
    accounts: {
      company: &quot;Company 03&quot;,
      id: 3
    }
  }, {
    users: {
      account_id: '',
      email: &quot;user03@domain&quot;,
      id: 3
    },      
    accounts: {
      company: null,
      id: null
    }
  }]
  </code></pre>
  <p>How can I achieve this?</p>
  <p>I tried:</p>
  <pre><code>SELECT users.id AS users.id, users.account_id AS users.account_id, users.email AS users.email, accounts.id AS accounts.id, accounts.company AS accounts.company FROM users LEFT JOIN accounts ON accounts.id=users.account_id
  -&gt; Error
  </code></pre>