- Code: Select all
var values = ['value1', 'value2', 'value3'];
var query = "SELECT columnA FROM myTable WHERE columnB = 'someValue' AND (";
values.forEach(
function(val) {
query += " columnC = '"+val+"' OR ";
}
);
query += " 1=1)"; //avoiding syntax error with a trailing 'OR'
I'd like to use Query Builder instead of using a query string, but I don't know how to add the list of OR conditions. Any ideas?