Reputation: 101
I have a data table called Movie_Stars. I want to update multiple values, but they are all in the same column. Here's what I have:
update movie_stars
set movie_category = 'Family'
where movie_category = 'Drama'
and set movie_category = 'Children'
where movie_category = 'Cartoon'
and set movie_category = 'Teen'
where movie_category = 'Action';
But this generates the error "invalid user.table.column, table.column, or column specification". So what is the right column specification?
Upvotes: 2
Views: 1343
Reputation: 521249
Use a CASE
expression:
update movie_stars
set movie_category = case when movie_category = 'Drama'
then 'Family'
when movie_category = 'Cartoon'
then 'Children'
when movie_category = 'Action'
then 'Teen'
end
where movie_category in ('Drama', 'Cartoon', 'Action')
Upvotes: 2