>  기사  >  백엔드 개발  >  怎么替换MYSQL中某字段的内容,参数替换

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

WBOY
WBOY원래의
2016-06-23 13:44:35943검색

比如内容是

*********.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)) ) 
少粘了一层括号



搞定了,非常感谢
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.