Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从数据库中删除行的某些部分(一组数据库行中的值)_Php_Mysql_Sql Delete_Find In Set - Fatal编程技术网

Php 从数据库中删除行的某些部分(一组数据库行中的值)

Php 从数据库中删除行的某些部分(一组数据库行中的值),php,mysql,sql-delete,find-in-set,Php,Mysql,Sql Delete,Find In Set,我想删除mysql中的一部分行。像这样: 我的排:1,2,3,4 我想做到:1,2,3 我该怎么做 我知道用这个代码可以做到,但是有更好的方法吗 updatetable SET message=REPLACE(message,”,4“,”),其中id=1为了安全起见,首先要在测试服务器中测试代码 如果你要替换,4,mysql也要替换,40 您必须更改字符串 ,1,2,3,4 您必须替换,4,,这样才能正常工作 UPDATE Table SET message = CASE WHEN messag

我想删除mysql中的一部分行。像这样:

我的排:1,2,3,4

我想做到:1,2,3

我该怎么做

我知道用这个代码可以做到,但是有更好的方法吗


updatetable SET message=REPLACE(message,”,4“,”),其中id=1

为了安全起见,首先要在测试服务器中测试代码

如果你要替换,4,mysql也要替换,40

您必须更改字符串

,1,2,3,4

您必须替换,4,

,这样才能正常工作

UPDATE Table SET message = CASE
WHEN message LIKE '4,%'
THEN // enter code here to replace '4,' in message with ''
WHEN message LIKE '%,4,%'
THEN // enter code here to replace ',4,' in message with ','
WHEN message LIKE '%,4'
THEN // enter code here to replace ',4' in message with ''
ELSE // this means all other occurances of 4 like 14,41,44,etc do nothing here or skip this else condition
END;

值1,2,3,4在一列中,对吗?如果u更新列,例如update Table SET message=“1,2,3”,其中id=1,那就好了<代码>更新表设置消息=“1,2,3”,其中id=1试试这个…@KanishkaPanamaldeniyayeah@annampriyatam如果价值太高,我应该写下所有这些???我可以使用
DELETE
实现这一点,这就是为什么他在WHERE条件中使用ID:)