問題描述
SELECT * FROM people
WHERE
university='2'
AND MATCH (lname,fname) AGAINST ('+massive' IN BOOLEAN MODE)
OR (fname LIKE '%box%' OR lname LIKE '%box%')
此查詢允許過濾結果而不是 university='2'
我將如何更新它,以便它嚴格只顯示大學 = 2 的結果
This query is allowing results to filter through other than those of university='2'
how would I update this so it strictly only shows results where university = 2
我將全文搜索與 LIKE 結合使用的原因是全文搜索的字母數最少,而且因為我使用的是共享主機計劃,所以我無法修改設置.因此,我將全文和 LIKE 結合起來以適應
The reason I have combined fulltext search with LIKE is because of the minimum letter count that full text search has and because I am on a shared hosting plan I am unable to modify the settings. As a result I have combined both full text and LIKE in order to accommodate
推薦答案
修正括號
SELECT * FROM people
WHERE
university='2'
AND (MATCH (lname,fname) AGAINST ('+massive' IN BOOLEAN MODE)
OR fname LIKE '%box%'
OR lname LIKE '%box%')
AND
的優先級高于 OR
,所以 university = '2'
只是與 MATCH
結合使用,而不是 fname/lname
測試.
AND
has higher precedence than OR
, so university = '2'
was only being combined with MATCH
, not with the fname/lname
tests.
這篇關于SQL 語句忽略了 where 參數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!