带有布尔值的 Mysql 电子邮件搜索给出错误值 [英] Mysql Email search with boolean giving bad values
问题描述
我的搜索查询有问题.我正在搜索电子邮件.
i have problem with my search query. I'm searching for emails.
我有这样的搜索查询:
$query = sprintf("SELECT mailer_subscribers.id, mailer_subscribers.email, mailer_subscribers.status,mailer_segmentlinker.segment_id, mailer_segmenten.segmentnaam FROM mailer_subscribers
JOIN mailer_segmentlinker ON mailer_subscribers.id=mailer_segmentlinker.subscriber_id
JOIN mailer_segmenten ON mailer_segmentlinker.segment_id=mailer_segmenten.id
WHERE MATCH (email) AGAINST ('%s*' IN BOOLEAN MODE)", $key);
但是当我在示例john.smith
"中输入关键字时,它会返回所有具有相同名称或姓氏的值
But when i am typing a keyword in example "john.smith
", it returns me all values that has the same name or surname
john.smith@example.com
john.notsmith@example.com
smith.hendrix@example.com
josh.josh@smith.com
我需要它会给我一个带有 john.smith
的列表.
i need that it will give me just list with john.smith
.
帮助我的解决方案是:WHERE mailer_subscribers.email LIKE '%%%s%%'", $key);
推荐答案
尝试将您的关键字放在双引号中以搜索准确的词组.
Try to put your keyword in double quotes to search for the exact phrase.
... AGAINST ('\"%s*\"' IN BOOLEAN MODE) ...
'苹果香蕉'
查找至少包含两个单词之一的行.
'apple banana'
Find rows that contain at least one of the two words.
'一些话"'
查找包含确切短语some words"的行(例如,包含一些智慧词"但不包含一些噪音词").
'"some words"'
Find rows that contain the exact phrase "some words"
(for example, rows that contain "some words of wisdom" but not "some
noise words").
这篇关于带有布尔值的 Mysql 电子邮件搜索给出错误值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!