title: MySQL how to select into JSON ARRAY
body: <p>in MySQL 5.7 we have the JSON_ARRAY object. I'd like to perform something similar to a <code>SELECT GROUP_CONCAT(field)</code> but with the results into a JSON_ARRAY. </p>
  
  <p>My current query is:</p>
  
  <pre><code>SELECT GROUP_CONCAT(name) FROM users;
  </code></pre>
  
  <p>result: john,michael,sofia</p>
  
  <p>I'd like the result to be: ["john","michael","sofia"]</p>
  
  <p>My current solution is:</p>
  
  <pre><code>select @j:=json_array_append(@j,'$',name) from users
  </code></pre>
  
  <p>But that's very inefficient since it's re-calculated for every row. Is it possible to achieve that more efficiently?</p>