0

Is it possible to match against words that begin or end with the searchstring?

Example:

I want to find a column that contains the word "pineapple". I want to find that row by searching for "pine" or just "apple" if that's possible.

Can this be done?

Current code, if it helps:

SELECT id
FROM movies
WHERE MATCH (movies.movie_title)
AGAINST ('+word1 +word2' IN BOOLEAN MODE)
4

1 回答 1

0

对于您的示例:

select 'pineapple' regexp 'pine|apple';

对于更一般的情况,如果您可以使用准备好的语句,您可以在构建查询时为正则表达式字符串添加任何您想要的内容。如果有多个要匹配的内容,您可以构建一个复杂的表达式,或者针对结果和循环进行子选择,或者自连接。有很多方法可以解决这个问题。

于 2012-10-06T12:48:04.303 回答