2016-04-29 62 views
0

我需要將alasql輸出設置爲Array。可能嗎?如何將alasql輸出設置爲Array

我沒有找到任何方法對本

var pre = document.getElementById('pre'); 
 
var keys = Object.keys(alasql).map(function(e) { 
 
    return [e]; 
 
}); 
 
var qLikes = alasql('SELECT * FROM ? WHERE [0] LIKE "%uery%"', [keys]); 
 
pre.innerHTML = JSON.stringify(qLikes, null, ' '); 
 
var pre = document.getElementById('pre');
<script src="https://cdn.rawgit.com/agershun/alasql/develop/dist/alasql.min.js"></script> 
 
<pre id="pre"></pre>

回答

3

隨着AlaSQL你可以在前面加上COLUMN OF到您的SQL擺脫代表數據集中的第一列值的數組。

var qLikes = alasql('COLUMN OF SELECT * FROM ? WHERE [0] LIKE "%uery%"', [keys]); 

var pre = document.getElementById('pre'); 
 
var keys = Object.keys(alasql).map(function(e) { 
 
    return [e]; 
 
}); 
 
var qLikes = alasql('COLUMN OF SELECT * FROM ? WHERE [0] LIKE "%uery%"', [keys]); 
 
pre.innerHTML = JSON.stringify(qLikes, null, ' '); 
 
var pre = document.getElementById('pre');
<script src="https://cdn.rawgit.com/agershun/alasql/develop/dist/alasql.min.js"></script> 
 
<pre id="pre"></pre>

+0

那就是我想要的。我不明白爲什麼我沒有想到這個?謝謝! – oshliaer

+0

[MATRIX修飾符](https://github.com/agershun/alasql/wiki/MATRIX)也很好。 – oshliaer