I have got an issue with problem named in topic.
I am trying to update multiple rows in table in one query depending on specific id of row. Unfortunatelly rows I want to update are text type of data (with numeric data it’s easy). This is my query:
UPDATE table SET column = CASE
WHEN id = 2 THEN column = column + ', 100'
WHEN id = 3 THEN column = column + ', 10'
[...]
ELSE column
END;
Data in column is imploded from php so it looks like:
id | column
------------
2 | 5, 6, 20
3 | 7, 12, 200
After executing a query i would like to have:
id | column
------------
2 | 5, 6, 20, 100
3 | 7, 12, 200, 10
How to add those values to specified rows? For now it changes ‘column’ row with id 2 and 3 to 0 (like it was an integer type of value).
I also would like to ask you how to erase specific value from column isntead of adding it:
id | column
------------
2 | 5, 7, 20
3 | 7, 12, 200
and i want to remove ‘7, ‘ from both rows – with id 2 and 3 so after query it looks like this:
id | column
------------
2 | 5, 20
3 | 12, 200
Any help would be appreciated – i got stuck with it :/
For Insertion:
For Removing you can do like dis. Sorry ,I can’t executes the query right now.Not Tested!
For Updating: If you want to change the value of 7 to 14