I am searching a database for names of schools. One of the schools around here is named E.O. Green. The issue I'm having, is if someone types "E.O. Green" they naturally get the school in the list of results. However if a someone types "EO Green" it is not displayed, but it should be.
Here is the query:
SELECT DISTINCT name
FROM donations
WHERE name LIKE '%$query%'
ORDER BY CASE WHEN name LIKE '$query%' THEN 1
WHEN name LIKE '%$query' THEN 3
ELSE 2 END
LIMIT 8
Is there a solution to this that I am just overlooking?
This is not a question about stripping punctuation in PHP, this is a question about ignoring punctuation in the database in a MySQL query.
[EDIT] The solution apparently is to do a replace on the MySQL Query
WHERE REPLACE($field, '.', '') LIKE '%$query%'
and then also strip punctuation from the users input
$query = str_replace(".", "", $query);
which accomplishes what I'm after, but I'm still curious if there is a simpler way. Although I will call this solved for now, as this does the job.