Method 1 - Store additional column
First method is to store additional column in your artists table with only a latin characters in it (eg. beyonce
).
Method 2 - Update the LIKE query
MySQL have the ability to replace exacly one character with a wildcard. In your case the query would look like this:
SELECT *
FROM `#__artists`
WHERE `artist` LIKE "beyonc_"
This query would match:
- Beyoncé
- Beyonce
- Beyonci
- Beyonct
But would not match:
Method 3 - Use a full text search
Last method is to use full text search. It would require some changes in table. The columns you try to match against would need to be of type Text
. Then you can run a query like this:
SELECT *
FROM `#__artists`
WHERE
MATCH (`artist`) AGAINST ('Beyonce' IN NATURAL LANGUAGE MODE)
This should return all the results that match a string.
Alternatively you can provide a score column like this:
SELECT
*, MATCH (`artist`) AGAINST ('Beyonce' IN NATURAL LANGUAGE MODE) AS `score`
FROM `#__artists`
WHERE `score`>0
and decide what results are best by checking score
column. To read more about full text search click the link above.
LIKE
, you want to allow accented or non-accented letters to qualify. Do you have a short list (perhaps 4 or 5 different values that express the scope of this issue) of realistic values so that a fully resolving recommendation can be made? Does your Joomla site have a primary language or is it multilingual? What is the charset and collation of your table? stackoverflow.com/q/10023776/2943403 , stackoverflow.com/q/37665452/2943403