mysql 如果另一个不为空则更新值

mysql update value if another one is not null

这个查询有什么问题?

UPDATE `order` SET `total_no_vat` = IF(`total` IS NULL,NULL,(`total`/(1.10)));

我收到无法解释的错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') )' at line 1

有线索吗?

你可以简单地做:

UPDATE `order` SET `total_no_vat` = `total`/(1.10);

如果 totalNULL,则 total/(1.10) 计算为 NULL