MySQL字符串替換我有一列包含URL(id,url):http://www.example.com/articles/updates/43http://www.example.com/articles/updates/866http://www.example.com/articles/updates/323http://www.example.com/articles/updates/seo-urlhttp://www.example.com/articles/updates/4?something=test我想把“更新”改為“新聞”。用腳本可以做到這一點嗎?
3 回答

慕沐林林
TA貢獻2016條經驗 獲得超9個贊
加上WHERE條款-
update tabelName set columnName=REPLACE(columnName,'from','to') where condition;
在沒有地方條款的情況下-
update tabelName set columnName=REPLACE(columnName,'from','to');
注意:以上查詢如果直接用于更新表中的記錄,如果您希望在SELECT查詢中進行查詢,且數據不應在表中受到影響,則可以使用以下查詢-
select REPLACE(columnName,'from','to') as updateRecord;
添加回答
舉報
0/150
提交
取消