在 mysql 的 IF 函数中使用 current_timestamp()
Usage of current_timestamp() in IF function in mysql
我无法在 mysql 中的 IF 函数中使用 current_timestamp()。为什么会这样?
有什么方法可以超越吗?
在 Microsoft excel 中,我们可以在 IF() 中使用 Today()。在 mysql 中有类似的东西吗?
您可以使用now()、curdate()。你到底想做什么?
例如在 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)
我无法在 mysql 中的 IF 函数中使用 current_timestamp()。为什么会这样? 有什么方法可以超越吗?
在 Microsoft excel 中,我们可以在 IF() 中使用 Today()。在 mysql 中有类似的东西吗?
您可以使用now()、curdate()。你到底想做什么?
例如在 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)