PostgreSQL search and replace where condition

▼魔方 西西 提交于 2020-01-26 04:34:12

问题


I am trying to save some manual time by search and replacing in my PostgreSQL database.

I have a table called Products_Colors where i'd like to replace all text in column color_image where column color_id is equal to 21.

UPDATE 
   Product_Colors
SET 
   color_image = REPLACE(color_image,"cars/car_2018.webp","cars/car_2019.webp")
WHERE 
   color_id = 21

Would this be correct syntax?


回答1:


I think you need a query like this :

UPDATE Product_Colors
SET color_image = 'cars/car_2019.webp'
WHERE color_id = 21 and color_image = 'cars/car_2019.webp'


来源:https://stackoverflow.com/questions/59040712/postgresql-search-and-replace-where-condition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!