Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要从 MySQL 表中选择一个 max(date),并将日期和时间的每个部分放在一个单独的变量中。
就像是:
select max(date) as year, month, day, hour, minute, second from table
我该怎么做?
你可以这样做:
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