是否可以在同一语句中使用AND和OR查询websql数据库?
这不起作用:
tx.executeSql('SELECT * FROM people
WHERE name="'+name1+'" OR name="'+name2+'"
AND category=1', [], function (tx, results) {
这两个都做到了:
tx.executeSql('SELECT * FROM people
WHERE name="'+name1+'" OR name="'+name2+'",
[], function (tx, results) {
tx.executeSql('SELECT * FROM people
WHERE name="'+name1+'"
AND category=1', [], function (tx, results) {
是不是可以实现这个,还是我的语法/查询不正确?
答案 0 :(得分:0)
事实证明我应该在发布之前尝试更多,在查询的OR部分添加括号以允许它工作:
tx.executeSql('SELECT * FROM people
WHERE (name="'+name1+'" OR name="'+name2+'")
AND category=1', [], function (tx, results) {