-
Notifications
You must be signed in to change notification settings - Fork 664
Into
Mathias Rangel Wulff edited this page Feb 28, 2017
·
8 revisions
Syntax:
SELECT ... INTO (table|into-function);
INSERT INTO table VALUES value1, value2, ...;
Into table
alasql('SELECT * INTO City FROM Capital');
alasql('SELECT * INTO AfrikanCountries FROM Countries WHERE Country = "Afrika"');
Into external file (into-functions)
alaslq('SELECT * INTO CSV(‘city.csv’) FROM City');
Into stdout (for Node.js):
alasql('SELECT * INTO TXT() FROM City');
You can save data into parametes array. In this case AlaSQL append records to existing array:
var data = [{a:1},{a:2}]; // Source array
var resdata = [{a:0}]; // Destination array
var res = alasql('SELECT * INTO ? FROM ? WHERE a<1',[resdata,data]);
AlaSQL returns in res
== 1 - number or records and resdata
equals to [ { a: 0 }, { a: 2 } ]
Example of data format conversion from XLSX to CSV:
alasql('SELECT * INTO CSV("parts.csv") FROM XLSX("parts.xlsx") WHERE Qty > 10');
alasql('SELECT * INTO TXT("cities.txt") FROM cities');
See also: FROM
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo