在Mysql表行中进行文本搜索,如果存在与命令相关的删除/更新

I have some columns in my MySQL table and some descriptions in it,

id / name / descriptions
1  / John / a1b01,Value 1,2,1,60|a1b01,Value2,1,1,50|b203c,Value 1,0,2,20
2  / Sam  / a1b01,Value2,2,3,50|b203c,Value 2,0,0,45
3  / Nick / a1b01,Value 1,2,1,60|a1b01,Value2,1,1,50
...

as you can see for different people, some variables are same Value 1, Value2 (can include space)/ a1b01, b203c etc. because, count of descriptions can vary I can't separate them.

I need two MySQL commands that will;

  • search for two variables (eg : "a1b01", "Value 1", these'll be taken from a function )
  • if both values found in related part then function will delete/update record

I think I should use a function like that

function do_action (command,code,desc,new1,new2,newresult) {
if (command == "delete") {
    // First SQL command to delete the founded part
    // but the ramains part should be kept
    // so final result would be : a1b01,Value2,1,1,50|b203c,Value 1,0,2,20 (for John)
  } elseif (command == "update"){
    // Second SQL command that update the founded part
    // Update founded part
    // so final result would be : a1b01,Value 1,new1,new2,newresult|a1b01,Value2,1,1,50|b203c,Value 1,0,2,20 (for John)
  }
}

but I have no idea which MySQL commands should I use?
All your solution, advice or improvement are welcome.

EDIT : Used Language is PHP, I am sending data from a php page (index.php) via Jquery's post method, then a php file (data.php) gets these parameters and executes on MySQL database.
Actually may be there is no way other than PHP driven solution, but simply I asked for a php+MySQL function that;
Function takes some parameters and searches for if second+third parameters (code,desc) are exist together in any description row in table (searching), then let function update this part (replace with new ones) or delete record up to first parameter (command -> delete/update)

Split the problem into several steps:

  • Determine how you can access the database. (You don't give any indication of what language you are using and you don't seem to know yet how to access the database.)
  • Figure out if it is possible to employ a better, normalized data structure.
  • If it is, your task is a piece of cake.
  • If not, you have to first read the values field from the entry you want to update and find the part you want to be replaced using your procedural language. (There is no regex replace in MySQL.)
  • Then assemble a new values string using not SQL but your procedural language.
  • If you don't want that for whatever reason (you asked for a MySQL command), you can use the REPLACE function to update the value: UPDATE the_table SET values = REPLACE(values, "a1b01,Value 1,2,1,60", "Value 1,new1,new2,newresult"