假如表名为user,表如下

id devid
1 1,2,3,12,13,14

要删除表user的devid字段中的1的值,注意12,13,13是不能删除

php语法如下:

$delnum = 1;
$id =1;
$sql
= "update user set devid = trim(both ',' from replace(concat(',', devid, ','), ',$delnum,', ',')) where id = '$id'"; if ($con->exec($sql)) { echo 1; }

sql语法如下:

update `user` set devid = trim(both ',' from replace(concat(',', devid, ','), ',1,', ','))

 

相关文章:

  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
  • 2021-12-04
  • 2021-05-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
相关资源
相似解决方案