在 SQL 中使用一个命令 - 我需要将单词 'Cars' 的所有实例更改为 'Zip-Cars',这包括将 'Cars 2' 更改为 'Zip-Cars 2'

Using One command In SQL - I need to change all instances of the word 'Cars' to 'Zip-Cars', this includes 'Cars 2' to be changed to 'Zip-Cars 2'

CREATE DATABASE movies_200186807;

USE movies_200186807;

CREATE TABLE movies_200186807 (

movie_name   VARCHAR(50) NOT NULL PRIMARY KEY,

release_date DATE NOT NULL,

cost         DEC(4) NOT NULL,

revenue      DEC(4) NOT NULL
);


INSERT INTO movies_200186807 (movie_name, release_date, cost, revenue)

VALUES


('Toy Story', '1995-11-22',30 , 364),

('Toy Story 2', '1999-11-24',90 , 511),

('Toy Story 3', '2010-06-18', 200, 1070),

('A Bugs Life', '1998-11-25', 60, 363),

('Monsters Inc', ' 2001-11-02', 115, 560),

('Finding Nemo', '2003-05-30', 94, 906),

('The Incredibles', '2005-11-04', 92, 615),

('Cars', '2006-06-09', 120, 462),

('Cars 2', '2011-06-24', 200, 560),

('Ratatouille', '2007-06-29', 150, 626),

('Wall-E', '2008-06-27', 180, 533),

('Up', '2009-05-29', 175, 731),

('Brave', '2012-06-22', 185, 555),

('Monster University', '2013-06-21', 200, 744),

('Planes', '2013-08-09', 50, 220);


Here is my table I have created called movies_200186807.

I need to change all instances of the word 'Cars' to 'Zip-Cars', this includes 'Cars 2' to be changed to 'Zip-Cars 2'  




I have tried multiple times this I what I have:



--This select statements shows the 2 movies I need to change

SELECT movie_name

FROM movies_200186807

WHERE movie_name LIKE 'Cars%'; 





--Here is my query, It runs but does not change the movie_name to ''Zip Cars' AND 'Zip Cars 2'

UPDATE movies_200186807

SET movie_name = replace(movie_name, 'Zip-Cars', 'Zip-Cars 2') 

WHERE movie_name LIKE '%Cars%';

任何建议,

谢谢

代替'Cars' to 'Zip-Cars'而不是Zip-Cars' to 'Zip-Cars 2'

UPDATE movies_200186807
SET movie_name = replace(movie_name, 'Cars', 'Zip-Cars') 
WHERE movie_name LIKE '%Cars%';

这将首先将 Cars 替换为 Zip-Cars,然后将 Cars 2 替换为 Zip-Cars 2

UPDATE movies_200186807
    SET movie_name = replace(replace(movie_name, 'Cars', 'Zip-Cars'), 'Cars 2', 'Zip-Cars 2')
    WHERE movie_name LIKE '%Cars%'

;