Issue: I am using the MYSQL and PHP latest versions. We are facing the issue in the MYSQL FULLTEXT search. It does not work with the special characters.
Example: In the domains table, 'name' field have the following three values:
1. https://www.google.com
2. https://www.yahoo.com
3. https://www.trafe.com
If i am using the search term https://www.google.com
, it will show all the above three values as result but the correct answer is https://www.google.com.
Query:
SELECT name
FROM domains
WHERE MATCH (name) AGAINST ('https://www.google.com*' IN BOOLEAN MODE);
Actual result: https://www.google.com
A full-text index in MySQL is an index of type FULLTEXT . Full-text indexes can be used only with InnoDB or MyISAM tables, and can be created only for CHAR , VARCHAR , or TEXT columns.
Use double quote: https://dev.mysql.com/doc/refman/5.1/en/fulltext-boolean.html
A phrase that is enclosed within double quote (“"”) characters matches only rows that contain the phrase literally, as it was typed.
For example:
SELECT name
FROM domains
WHERE MATCH (name) AGAINST ('"https://www.google.com"' IN BOOLEAN MODE);
Result:
name
https://www.google.com
If you really want that *
you can search for '"https://www.google.com*"'
(*
is put inside the double quote).
Here is SQL fiddle: http://sqlfiddle.com/#!9/a6458/6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With