How to remove duplicate records with merging values?
I have the table with id (integer pm key), val1 (text), val2 (text).
Current situation:
------------------
id val1 val2
1. john sam
2. larry tom
3. john joe
I want to have:
---------------
id val1 val2
1. john sam, joe
2. larry tom
...
Thank you very much for your help.
As far as I know, you can’t do this, you can’t
UPDATEandDELETEin one single query. However, you can do this as twoUPDATEandDELETEqueries like so:This will make the changes you want.
Note that: You have to put these two queries in one TRANSACTION.
SQL Fiddle Demo
These two queries will make your table looks like: