Mysql的批量修改

Mysql中
咱們常常用到update對一個對象進行修改。
若是某個filed的內容是123xyz890的話呢,經過下面的修改將會把該對象變爲123abc890。sql

update `table_name` set `filed_name = 123abc890 where .....;

若是咱們要將全部包含有xyz的對象中的xyz都變成abc的話呢,能夠經過replace配合update 實現。以下:code

update `table_name` set filed_name = REPLACE(filed_name,"xyz","abc");

若是要對修改的對象羣進一步的約束的話,也能夠後面加where對象

update `table_name` set filed_name = REPLACE(filed_name,"xyz","abc") where ....;
相關文章
相關標籤/搜索