Tim
Tim

Reputation: 792

MySQL match against string containing percentage char

I am trying to find the value in db row, that include percentage sign.

For example, there is a value of a row "reduced by 10%".

I need to filter results that have "10%" in them, not just "10".

I was trying to

SELECT name, MATCH(name) AGAINST('10\%') AS score 
FROM mytable 
ORDER BY score DESC

But it returned all the results with "10".

Any ideas?

Upvotes: 1

Views: 1490

Answers (1)

Korhan Ozturk
Korhan Ozturk

Reputation: 11308

Try the following:

SELECT name, MATCH(name) AGAINST('+10\%' IN BOOLEAN MODE) AS score 
FROM mytable 
ORDER BY score DESC

Upvotes: 1

Related Questions