发布网友 发布时间:2022-04-08 06:36
共1个回答
热心网友 时间:2022-04-08 08:06
UPDATE mac_vod SET d_playerfrom=REPLACE(d_playerfrom, 'HTML', '.YOUKU');追问这样不是 所有的都替换掉了??? 我要的是如果D_PLAYERFROM值是YOUKU 把d_URL里的.HTML替换成.YOUKU追答UPDATE mac_vod SET d_URL
=REPLACE(d_URL, 'HTML', '.YOUKU')
where d_playerfrom ='YOUKU'
For example:
mysql> create table t4
-> (id int,name varchar(50));
Query OK, 0 rows affected (0.05 sec)
mysql> insert into t4 values(1,'adfahttp'),(2,'asdfd'),(2,'sdhttp'),(1,'xdads');
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> select * from t4;
+------+----------+
| id | name |
+------+----------+
| 1 | adfahttp |
| 2 | asdfd |
| 2 | sdhttp |
| 1 | xdads |
+------+----------+
4 rows in set (0.00 sec)
mysql> update t4 set name=replace(name,'http','_youku_') where id=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 2 Changed: 1 Warnings: 0
mysql> select * from t4;
+------+-------------+
| id | name |
+------+-------------+
| 1 | adfa_youku_ |
| 2 | asdfd |
| 2 | sdhttp |
| 1 | xdads |
+------+-------------+
4 rows in set (0.00 sec)
mysql>