This query:
SELECT name,
REPLACE(REPLACE(REPLACE(LOWER(name),' ',''),'-',''),':','') AS formattedName,
GROUP_CONCAT(service)
FROM movies
GROUP BY formattedName
HAVING COUNT(CASE WHEN name like "%von brom%" THEN 1 END) > 0;
Gives me the following result:
+---------------------------------------------+---------------------------------------+---------------------+
|name |formattedName |GROUP_CONCAT(service)|
+---------------------------------------------+---------------------------------------+---------------------+
|LasseMajas detektivbyrå: Von Broms hemlighet |lassemajasdetektivbyråvonbromshemlighet|sfanytime |
+---------------------------------------------+---------------------------------------+---------------------+
|LasseMajas detektivbyrå - Von Broms hemlighet|lassemajasdetektivbyråvonbromshemlighet|boxer |
+---------------------------------------------+---------------------------------------+---------------------+
|LasseMajas detektivbyrå - Von Broms hemlighet|lassemajasdetektivbyråvonbromshemlighet|viaplay |
+---------------------------------------------+---------------------------------------+---------------------+
All the values in the "formattedName" column look identical, so why aren't the rows grouped together?
If I use WHERE
to filter the rows, instead of HAVING
, it actually seems to work. It gives me one row as result, with sfanytime,boxer,viaplay
in the GROUP_CONCAT(service)
column. But I need to have the filter in HAVING
, because else I won't get all the information I need in some cases.
It also works if I replace GROUP_CONCAT(service)
with just service
. It only fails if I both use GROUP_CONCAT
and HAVING
All of this is from phpMyAdmin on a database on https://www.one.com. If I try to do the same thing on a identical local database on my own computer with the MySQL workbench, everything works as expected, and the rows are grouped together in all of the cases (HAVING
/WHERE
,with or without GROUP_CONCAT
).
What causes this weird behavior? Could it maybe have something to do with the special character "å"?
My character_set_server
is set to utf8
on the local database, and to latin1
on the one.com database.
Calling SELECT @@version;
on the one.com database gives me:
5.5.45-MariaDB-1~wheezy
And on the local database it gives me:
5.7.9-log