I would like to concatenate multiple values and remove duplicates (case-insensitive) in the same field with SQL only.
Without using a unique key or stored procedure.
Ex.
Toto;toto1;titi;TOTO;toto1;tata;
in
Toto;toto1;titi;TOTO;tata;
Here is my SQL model:
UPDATE users SET pseudo = CONCAT_WS(';', pseudo, 'NEWS_VALUE') WHERE id = '1';
I can not handle duplicates
Thank you for your help
Best Answer
You need to create a sub-query with distinct values and then join it to your main table and update, like this:
You will need a temporary numbers table:
SQL Fiddle that shows how to split using numbers table