Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
142 views
Welcome To Ask or Share your Answers For Others

1 Answer

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'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...