开发者

mysql fulltext multiple words from one form input?

开发者 https://www.devze.com 2023-03-18 08:45 出处:网络
I\'ve heared alot of similar discussion but I havent seen a direct solution. SELECT * FROM patient_db WHE开发者_运维知识库RE

I've heared alot of similar discussion but I havent seen a direct solution.

SELECT * FROM patient_db WHE开发者_运维知识库RE 
       MATCH ( Name, id_number ) AGAINST ('%$term%' IN BOOLEAN MODE);

Isn't there something simple around my '%$term%' I need to do to enable multiple-word searching?


Unfortunately, there is no way to directly say, "I want one of these n words" in a MySQL fulltext query. Your only real option is

SELECT * FROM patient_db WHERE 
       MATCH ( Name, id_number ) AGAINST ('%$term%' IN BOOLEAN MODE)
       OR MATCH ( Name, id_number ) AGAINST ('%$term2%' IN BOOLEAN MODE)
       OR MATCH ( Name, id_number ) AGAINST ('%$term3%' IN BOOLEAN MODE)
       ;

Just curious, but why are you searching a column named id_number for text?

0

精彩评论

暂无评论...
验证码 换一张
取 消