JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgit.com/agershun/alasql/develop/dist/alasql.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/xlsx.full.min.js"></script>
<xmp id="output"></xmp>
JavaScript
print('Fill data')
var sql = "CREATE TABLE [Table] (Field1 string, Field2 integer, Field3 string);"
+"INSERT INTO [Table] VALUES ('new',2,'aaa'),('new',1,'bbb');"
+"SELECT * FROM [Table]"
var res = alasql(sql);
print(res)
print('Field3 included in SQL update to New21')
print(alasql.exec("UPDATE [Table] SET [Field1] = 'New21' WHERE ( [Field2] <= ( SELECT [Field2] FROM [Table] WHERE [Field3] = 'bbb' ))"))
print(alasql("SELECT * FROM [Table]"))
print('Field3 excluded in SQL update to New321')
print('Not working as the subquery cant access the params')
print(alasql.exec("UPDATE [Table] SET [Field1] = 'New21' WHERE ( [Field2] <= ( SELECT [Field2] FROM [Table] WHERE [Field3] = ? ))", ['bbb']))
print(alasql("SELECT * FROM [Table]"))
function print(x){
document.getElementById('output').textContent += JSON.stringify(x, null, '\t')+"\n";
}
print('AlaSQL v'+alasql.version)