mysql - Delete a specific value from a string ( string contains comma saperated values) -
for example if have table structure this.
table 1 id name value 001 rajesh 90,100,210,400 002 suresh 100,400,300,66 003 mahesh 200,500 004 virat 400,578,57
how can delete 400 suresh ?
delete value ="400" table1 name = 'suresh'
this doesnt work.
i recommend splitting values second table related via person's id. however, can use following query current situation:
update table1 set value = trim(both ',' replace(concat(',', value, ','), ',400,', ',')) name = 'suresh'
here's sql fiddle. reference, see mysql's string functions
Comments
Post a Comment