MySQL日期函数不接受子查询

时间:2016-05-19 04:38:07

标签: mysql

我正在尝试在MySQL v5.7.11中的TIMESTAMP函数中运行子查询。

SELECT TIMESTAMP(SELECT NOW() AS currentDate);

我收到错误说

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 'SELECT NOW() AS currentDate)' at line 1

我在这里做错了什么?

1 个答案:

答案 0 :(得分:1)

您需要在子查询中添加额外的括号对。

SELECT TIMESTAMP((SELECT NOW() AS currentDate));