求助一个有判断条件的更新语句

假设表里有两个日期类型的字段,其中一个为null, 要根据是否为null更新其中的一个,使用如下语句
->update table1 set case
->when col1 is null then col1
->when col2 is nul then col2
->end =curdate()
->where condition = ...
执行不成功,请指教错误。

作者: wjh_bh   发布时间: 2011-06-04

update table set col1 = ifnull(col1, now()), col2=ifnull(col2, now()) where condition.

作者: andrefun   发布时间: 2011-06-05

测试通过了,谢谢andrefun,你的思路更直接,也巧妙,我想的过于复杂了!

作者: wjh_bh   发布时间: 2011-06-05