JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdn.jsdelivr.net/npm/alasql@2"></script>
<xmp id="result"></xmp>
JavaScript
alasql("CREATE TABLE cities (city string, population string)");
alasql(`INSERT INTO cities VALUES ('%','1'), ('1%','2'), ('%1','3'), ('1%1','4'), ('_1','5'), ('1^1','6'), ('1!1','7'), ('"','2%')`);
// Case 1 : backslash ESCAPE char:
// OK: var res = alasql("SELECT * FROM cities WHERE (city LIKE '%^%%' ESCAPE '^') OR (population LIKE '2^%' ESCAPE '^') ORDER BY population DESC"); // =>returns 5 members
KO: var res = alasql("SELECT * FROM cities WHERE (city LIKE '%\%%' ESCAPE '\') OR (population LIKE '2\%' ESCAPE '\') ORDER BY population DESC"); // => no filter
// Case 2 : double quote ESCAPE char:
/* var res = alasql(`SELECT * FROM cities WHERE (city LIKE '%^"%' ESCAPE '^') OR (population LIKE 'n^%' ESCAPE '^') ORDER BY population DESC`); */
/* var res = alasql("SELECT * FROM cities WHERE (city LIKE '%^%%' ESCAPE '^') OR (population LIKE 'n^%' ESCAPE '^') ORDER BY population DESC); */
/* var res = alasql("SELECT * FROM cities WHERE (city LIKE '%^"%' ESCAPE '^') OR (population LIKE '2\\%' ESCAPE '\\') ORDER BY population DESC") */
showResult(res)
function showResult(x){
document.getElementById('result').textContent = JSON.stringify(x, null, '\t');
}