How can I search for "1-800-flowers" by "1800flowers" in MySQL?
I have the data "1-800-flowers", but I want to find it by "1800flowers".
How can I search for "1-800-flowers" by "1800flowers" in MySQL?
I have the data "1-800-flowers", but I want to find it by "1800flowers".
You're probably best off creating a second column that you fill with 1800flowers
(replacing all characters you want to ignore) and searching that. That way, you can make full use of indexing.
A quick way to convert all existing data would be
UPDATE table SET columnname_without_hyphens = REPLACE(columnname, "-", "");
The use of the replace function will kill any ability to use an index on the column, but:
select *
from YourTable
where replace(YourColumn, '-', '') = '1800flowers'