我需要将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>
答案 0 :(得分:5)
使用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>