我有一个名为 Movie_Stars 的数据表。我想更新多个值,但它们都在同一列中。这是我所拥有的:
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';
但这会生成错误“无效的 user.table.column、table.column 或列规范”。那么什么是正确的色谱柱规范呢?
最佳答案
使用CASE
表达式:
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')
关于oracle - 更新同一列中的多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40835603/