我需要从MySQL表中选择一个max(日期),并将日期和时间的每个部分放在一个单独的变量中。
类似的东西:
select max(date) as year, month, day, hour, minute, second from table
我该怎么做?
答案 0 :(得分: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