Add value of a SET list in MySQL

0

I want to add values in a 'list' (values separated by ',' which will then be used the 'split' function) in mysql, I am using this code: UPDATE clans SET Admins = concat(Admins, ',', 'NomeDoJogador') WHERE Name = 'NomeDoClan' , but when I add a value, 'list' is empty, the ',' is sent before the value, and this was only to happen if there were more than one value value on the 'list'. Code used to remove a player from the "list", if necessary: UPDATE clans SET Admins = REPLACE(REPLACE(Admins, ',NomeDoJogador', ''), 'NomeDoJogador', '') WHERE Name = '" + _clanName + "'

    
asked by anonymous 17.01.2017 / 06:11

1 answer

0

Instead of using CONCAT use CONCAT_WS :

UPDATE clans SET Admins = CONCAT_WS(',', Admins, 'NomeDoJogador') WHERE Name = 'NomeDoClan'
    
17.01.2017 / 12:02