Mysql中
我們經常用到update對一個對象進行修改。
如果某個filed的內容是123xyz890的話呢,通過下面的修改將會把該對象變為123abc890。
update `table_name` set `filed_name = 123abc890 where .....;
如果我們要將所有包含有xyz的對象中的xyz都變成abc的話呢,可以通過replace配合update
實現。如下:
update `table_name` set filed_name = REPLACE(filed_name,"xyz","abc");
eg:UPDATE `jeesite`.`sys_dict` SET TYPE = REPLACE(TYPE,"ftour","tour") //將字段中的ftour替換為tour
如果要對修改的對象群進一步的約束的話,也可以后面加where
update `table_name` set filed_name = REPLACE(filed_name,"xyz","abc") where ....;