MySQL Match Against Query Does Not Show Rows With Same Words

Here is my mysql search query:

mysql_query("SELECT films.*,
            MATCH(films.film_title) AGAINST ('$keyword \">$keyword\"' IN BOOLEAN MODE) AS score
       FROM films
       WHERE MATCH(films.film_title) AGAINST('$keyword \">$keyword\"' IN BOOLEAN MODE) >.8 ORDER BY score DESC, views DESC LIMIT 7",$dbh) 
        or die(mysql_error());

So, as a sample search. I have two films called “Arrival”, and I search “arrival”. It only returns one of the films. I can’t figure out why. Does Match Against avoid duplicates?

All feedback appreciated.


Assuming that you’re server-side language is PHP, you’re a sitting duck for SQL Injection attacks with that code! Also the mysql_* extension was removed from PHP as of version 7 of PHP.

What collation have you used for the table? Not all collations are case-insensitive

Yeah, it was some early code I had. I have the addslashes function being applied to the $keyword. variable.


If I change the title of one of the films the other will begin showing in the list of results. It’s very weird.

Figured it out. It wasn’t php/mysql result, but the json function was not allowing duplicates. I fixed it.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.