I need to find the word Lämmönmyyntipalvelut from the database. Only, in the database it is in a field, whose value has been a PHP array, converted into JSON using json_encode() and so the special characters are scrabled into hex unicode.
So my query is
SELECT * FROM table WHERE (services LIKE '%Lämmönmyyntipalvelut%')
No results. No surprise. Next, query with special characters converted:
SELECT * FROM table WHERE (services LIKE '%L\u00e4mm\u00f6nmyyntipalvelut%')
No results and I wonder why. Next I tested querying for only special character:
SELECT * FROM table WHERE (services LIKE '%\u00e4%')
Found what was supposed to find. Next I started adding stuff (L to beginning) to see where it went wrong:
SELECT * FROM table WHERE (services LIKE '%L\u00e4%')
No results. Another test:
SELECT * FROM table WHERE (services LIKE '%\u00e4mm%')
Found what was supposed to find.
So my conclusion is that the backslash is somehow messing things up, but I don't understand how?
EDIT:
Exact contents of services field:
["Neuvonta","L\u00e4mm\u00f6nmyyntipalvelut",
"Mets\u00e4-\/energiapuunkorjuupalvelut"]
Exact query:
SELECT id, uid, company_name, services, logo FROM rekisteroeidy_toimijaks
WHERE
(services LIKE '%L\u00e4mm\u00f6nmyyntipalvelut%' AND
services LIKE '%Mets\u00e4-\/energiapuunkorjuupalvelut%')
ORDER BY company_name ASC
I added some line breaks to help readability.
json_encode()
d result.