提问者:小点点

current_timestamp()在mysql中IF函数中的用法


我不能在MySQL的IF函数中使用current_timestamp()。 为什么会这样呢? 有什么方法可以超越它吗?

在microsoft excel中,我们可以在IF()中使用Today()。在MySQL中有类似的东西吗?


共2个答案

匿名用户

例如,在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()。 你到底想做什么?