0

我需要从 MySQL 表中选择一个 max(date),并将日期和时间的每个部分放在一个单独的变量中。

就像是:

select max(date) as year, month, day, hour, minute, second from table

我该怎么做?

4

1 回答 1

0

你可以这样做:

SELECT 
YEAR ( MAX(date) ) as year,
MONTH ( MAX(date) ) as month, 
DAY ( MAX(date) ) as day,
HOUR( MAX(date) ) as hour,
MINUTE( MAX(date) ) as minute,
SECOND( MAX(date) ) as second
from table
于 2015-05-13T16:08:54.317 回答