所以我有一个MySQL表,人们,数据库中有_Name,_Criminal,_Loyalist,_PrevJailed和三个人。
_Name | _Criminal | _Loyalist | _PrevJailed
-----------------------------------------------------------
John Mitt | 1 | 0 | 1
John Sample | 0 | 1 | 1
Jane Lastname | 0 | 0 | 1
搜索带有查询的人时
SELECT *
FROM people
WHERE `_Name` LIKE '%'
AND _Criminal = 1
AND `_Loyalist` = 0
AND `_PrevJailed` = 1
正如我预测的那样,它带来了约翰米特。但是在使用像这样的查询进行搜索时
SELECT *
FROM people
WHERE `_Name` LIKE '%'
AND _Criminal = 0
AND `_Loyalist` = 0
AND `_PrevJailed` = 1
它只会调出Jane姓。它应该是John Sample 和 John Mitt,因为他们以前都被判入狱。在这个问题上,我被困了三天。我当前的系统工作,你只需要在搜索时非常特定(即说出他们确切的'记录'(0,0,1等)。
答案 0 :(得分:0)
SELECT
*
FROM people
WHERE `_PrevJailed` = 1
AND (_Criminal = 0 OR `_Loyalist` = 0)