問題描述
SELECT * FROM people
WHERE
university='2'
AND MATCH (lname,fname) AGAINST ('+massive' IN BOOLEAN MODE)
OR (fname LIKE '%box%' OR lname LIKE '%box%')
此查詢允許過濾結(jié)果而不是 university='2'
我將如何更新它,以便它嚴(yán)格只顯示大學(xué) = 2 的結(jié)果
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 結(jié)合使用的原因是全文搜索的字母數(shù)最少,而且因為我使用的是共享主機(jī)計劃,所以我無法修改設(shè)置.因此,我將全文和 LIKE 結(jié)合起來以適應(yīng)
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
的優(yōu)先級高于 OR
,所以 university = '2'
只是與 MATCH
結(jié)合使用,而不是 fname/lname
測試.
AND
has higher precedence than OR
, so university = '2'
was only being combined with MATCH
, not with the fname/lname
tests.
這篇關(guān)于SQL 語句忽略了 where 參數(shù)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!