为什么 where 子句被忽略
Why is the where clause neglected
我正在尝试以下查询:
return mDb.query(DATABASE_TABLE1, asColumnsToReturn,
"NotificationDateFor like ?
OR FriendsName like ?" +"
AND TypeNotification <> 'Event'
AND RadioType <> '3'
ORDER BY DateToNotify ASC",
new String[] { value, value }, null,null, null);
但是我观察到在这种情况下对应的部分:
AND TypeNotification <> 'Event' AND RadioType <> '3'
被忽视了。可能是什么原因?
在documentation中可以看出,AND的优先级高于OR,所以一个NotificationDateFor
匹配就足以select一行:
sqlite> select 1 or 0 and 0 and 0;
1
你必须使用括号:
(NotificationDateFor LIKE ? OR FriendsName LIKE ?) AND TypeNotification <> 'Event' AND RadioType <> '3'
我正在尝试以下查询:
return mDb.query(DATABASE_TABLE1, asColumnsToReturn,
"NotificationDateFor like ?
OR FriendsName like ?" +"
AND TypeNotification <> 'Event'
AND RadioType <> '3'
ORDER BY DateToNotify ASC",
new String[] { value, value }, null,null, null);
但是我观察到在这种情况下对应的部分:
AND TypeNotification <> 'Event' AND RadioType <> '3'
被忽视了。可能是什么原因?
在documentation中可以看出,AND的优先级高于OR,所以一个NotificationDateFor
匹配就足以select一行:
sqlite> select 1 or 0 and 0 and 0;
1
你必须使用括号:
(NotificationDateFor LIKE ? OR FriendsName LIKE ?) AND TypeNotification <> 'Event' AND RadioType <> '3'