我不能在MySQL的IF函数中使用current_timestamp()。 为什么会这样呢? 有什么方法可以超越它吗?
在microsoft excel中,我们可以在IF()中使用Today()。在MySQL中有类似的东西吗?
例如,在if函数中使用current_timestamp()没有问题
select current_timestamp(),
if(1 = 1 , current_timestamp(),null);
生产
+---------------------+--------------------------------------+
| current_timestamp() | if(1 = 1 , current_timestamp(),null) |
+---------------------+--------------------------------------+
| 2020-07-08 12:29:29 | 2020-07-08 12:29:29 |
+---------------------+--------------------------------------+
1 row in set (0.001 sec)
您可以使用now(),curdate()。 你到底想做什么?