2

I have 2 similar DB, on 2 servers.
If i try to execute this request one each one :

SELECT u.lastname, MATCH (u.lastname) AGAINST ('Rod*' IN BOOLEAN MODE)
FROM user u
WHERE MATCH (u.lastname) AGAINST ('Rod*' IN BOOLEAN MODE) > 0 ;

On the first server, it give me results with a numeric value as score of the match against.

One the second one, I got the same results, so the where clause is really applied, but the score is always = to 0.

Do you have any idea ? I guess it could be a specific conf of mysql... but I don't know which one to check.

Thanks very much

Toon
  • 53
  • 3
  • 2
    You definitely shouldn't match both in select and where. – marekful Jun 05 '18 at 12:25
  • It's just an example... I need to select the Match Against if I want to know his value. This request leads me to the same issue : SELECT u.lastname, MATCH (u.lastname) AGAINST ('Rod*' IN BOOLEAN MODE) as score FROM user u HAVING score > 0 – Toon Jun 05 '18 at 12:44

1 Answers1

2

Select from a derived table:

SELECT lastname, score FROM (
SELECT u.lastname, MATCH (u.lastname) AGAINST ('Rod*' IN BOOLEAN MODE) AS score 
FROM user u 
) as derivedTable WHERE score <> 0 ORDER BY score DESC;
TheBigGris
  • 39
  • 6