Merge multiple rows together I have a table that looks more or less like this:

 user  is_su  last_login  roles-for_groups
+------+---+------------+----------------------------+
| rob  | 1 | 2018-02-09 | admin, read                |
+------+---+------------+----------------------------+
| gian | 0 | 2018-06-21 | prod_full_access, readOnly | 
+------+---+------------+----------------------------+
| gian | 0 | 2018-06-21 | prod_full_access, CCT      |  
+------+---+------------+----------------------------+
| rob  | 1 | 2018-02-09 | admin, write               |  
+------+---+------------+----------------------------+


and I would like to merge into a single row all the rows with the same user, in a way such that the table will look like this:

+------+---+------------+---------------------------------+--+
| rob  | 1 | 2018-02-09 | admin, read, write              |  |
+------+---+------------+---------------------------------+--+
| gian | 0 | 2018-06-21 | prod_full_access, readOnly, CCT |  |
+------+---+------------+---------------------------------+--+


How can I achieve this?
You need to create a temporary table with the merged data, then remove the old table and then rename the temporary table with the correct table name.

EXAMPLE:

CREATE TABLE table_temp SELECT user,is_su,last_login,GROUP_CONCAT(roles-for_groups) AS roles-for_groups FROM table1 GROUP BY user;


Check if table_temp is ok and then you can remove your old table.

DROP TABLE table1


The last step, rename the new/temporary table to the actual table name

RENAME TABLE table_temp TO table1;


PS: I'm assuming your table name is table1 because you never posted the name.