如何删除jsondecode中的特定值

My table

I have table called contracters_system i want to remove the particular value in contracter_id how can i do that ?

$plansarray = Array ( [0] => 4 [1] => 10 [2] => 47 );
$contractid = '21';


 foreach ($plansarray as $servicesecondarray){

            $servicequery = "select contracterid from contracters_system where planoption_id='$servicesecondarray'";
            $servicequeryresult = Yii::app()->db->createCommand($servicequery)->queryAll();

            $servicequery1 = "select contracterid from contracters_system where planoption_id <> '$servicesecondarray'";
            $servicequeryresult1 = Yii::app()->db->createCommand($servicequery1)->queryAll();


             $stack = json_decode($servicequeryresult[0]['contracterid'], true);
             array_push($stack, $contractid);


            if(empty($stack)){        
               $arraypush[] = $contractid; 
            } else {             
              $arraypush = $stack;
            }


             $finaldecode =  json_encode(array_unique($arraypush));
             if(!empty($finaldecode)){

              $updatequery = "update contracters_system set contracterid = '$finaldecode' where planoption_id='$servicesecondarray' ";
              $updateresult = Yii::app()->db->createCommand($updatequery)->query();

             }



            for($c=0;$c<count($servicequeryresult1);$c++){

              $jsondecode = json_decode($servicequeryresult1[$c]['contracterid']);
              //print_r($jsondecode);
              if(($key = array_search($_GET['id'], json_decode($servicequeryresult1[$c]['contracterid'])) !== false) {
                  unset(json_decode($servicequeryresult1[$c]['contracterid'])[$key]);
                 // echo "test".$key;

                   $updatequery = "update contracters_system set contracterid = '".unset($jsondecode[$key])."' where planoption_id='$servicesecondarray' ";
                   $updateresult = Yii::app()->db->createCommand($updatequery)->query();
              }

            }

I have value like 21 in table ["1","21"].My expected output is ["1"].

How can i achieve this in mysql and php ?

  1. Read that field value $value.
  2. decode it $decoded = json_decode($value)
  3. Traverse $decoded array
  4. Find the value and remove/unset
  5. Again json_encode($updated_array)
  6. Update this field value back to database