Php 为搜索改进我的SQL查询

Php 为搜索改进我的SQL查询,php,mysql,Php,Mysql,有人能帮我改进SQL查询吗。这是一个网站搜索。以下是查询: SELECT j_author.author_id as authorID, author_name, author_description, author_cat, author_city, author_state, points, (SELECT SUM(rate_value) FROM j_rating WHERE j_rating.author_id = authorID ) AS rating_value FROM

有人能帮我改进SQL查询吗。这是一个网站搜索。以下是查询:

SELECT j_author.author_id as authorID, author_name, author_description, author_cat, author_city, author_state, points, (SELECT SUM(rate_value) FROM j_rating WHERE j_rating.author_id = authorID ) AS rating_value
    FROM j_author
    JOIN j_author_category ON j_author.author_cat = j_author_category.author_cat_id
    WHERE author_name LIKE '%" . $keyword . "%'
    OR author_city LIKE '%" . $keyword . "%'
    ORDER BY rating_value DESC
这是可行的,但不是我想要的。例如,如果我搜索'edu'并且有一个名为educate的作者或城市,它将返回作者或城市。但如果搜索“受过教育的人”,则不会返回结果

我还尝试使用:

SELECT j_author.author_id as authorID, author_name, author_description, author_cat, author_city, author_state, points, (SELECT SUM(rate_value) FROM j_rating WHERE j_rating.author_id = authorID ) AS rating_value,             
MATCH(j_author.author_name, j_author.author_city) AGAINST ('$keyword' IN BOOLEAN MODE) AS score
FROM j_author  
JOIN j_author_category ON j_author.author_cat = j_author_category.author_cat_id
WHERE MATCH(j_author.author_name, j_author.author_city) AGAINST ('$keyword' IN BOOLEAN MODE)
ORDER BY `score` DESC
但每次我使用这个方法,当我搜索“edu”时,它都不会返回任何结果


我想要的是,如果“受过教育的人”是输入的搜索关键字,它应该使用“受过教育的人”和“人”作为单独的关键字进行搜索,并返回与任何关键字匹配的结果。此外,当“edu”是关键字时,它应该返回所有姓名或城市中带有edu的作者

如果您无法在将值传递到查询之前拆分文本,则您可能正在查找类似的内容:


如果您将查询分解为预定义字符,并对每个“标记”执行查询,您应该能够实现您的目标。

全文搜索不查找“子字符串”匹配项。它寻找单词,而不是单词的一部分。如果要搜索部分匹配项,需要搜索
edu*
谢谢。我会试试看