Heim  >  Artikel  >  Backend-Entwicklung  >  怎么替换MYSQL中某字段的内容,参数替换

怎么替换MYSQL中某字段的内容,参数替换

WBOY
WBOYOriginal
2016-06-23 13:44:35941Durchsuche

比如内容是

*********.php?haode=yes********789**********
*********.php?haode=yes********246**********
*********.php?haode=yes********221**********
*********.php?haode=yes********687**********
*********.php?haode=yes********215**********


需要替换成

*********.php?type=789********789**********
*********.php?type=246********246**********
*********.php?type=221********221**********
*********.php?type=687********687**********
*********.php?type=215********215**********






回复讨论(解决方案)

?abc替??1,2,3
update table set fields = REPLACE(fields, 'abc', '123');

?abc替??1,2,3
update table set fields = REPLACE(fields, 'abc', '123');



我主要是要把后面的哪数字复制到前面来呀

update tbl_name set field=REPLACE(field, 'haode=yes', CONCAT('type=', SUBSTRING_INDEX(SUBSTRING_INDEX(field, '</b>', 1), '<b>', -1))

update tbl_name set field=REPLACE(field, 'haode=yes', CONCAT('type=', SUBSTRING_INDEX(SUBSTRING_INDEX(field, '</b>', 1), '<b>', -1))


#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2

.... , -1)) ) 
少粘了一层括号

update tbl_name set field=REPLACE(field, 'haode=yes', CONCAT('type=', SUBSTRING_INDEX(SUBSTRING_INDEX(field, '</b>', 1), '<b>', -1))


可以给份完整代码吗,真心不懂SQL语句
数据库doudou
表名phome_ecms_news_data_1
字段newstext

.... , -1)) ) 
少粘了一层括号



搞定了,非常感谢
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn