【发布时间】:2020-10-15 13:54:26
【问题描述】:
update comments
set comment = case
when id % 7 = 0 then 'The universe is such an amazing thing.'
when id % 5 = 0 then 'I definitely read the article again.'
when id % 3 = 0 then 'This is interesting.'
when id % 2 = 0 then 'Very good article'
end
where id between 1 and 15;
它给了我错误:错误代码:1048。“评论”列不能为空! 我只想更新那些可以整除的女巫。 所有其他不可分割的我想保持不变。
【问题讨论】:
-
当
id等于11 或13 时,when子句都不成立,那么comment等于什么?您要么需要更多when子句或else子句。
标签: mysql sql sql-update case