MySQL 取得小时分钟部分

时间:2021-08-14 10:55:25

MySQL 取得小时分钟部分

SELECT `CpParkID` , DATE_FORMAT( `UPDATE_TIME` , '%H:%i' )FROM `cp_park`WHERE HOUR( `UPDATE_TIME` ) = '08'AND MINUTE( `UPDATE_TIME` ) = '59'

结果CpParkID DATE_FORMAT(`UPDATE_TIME`,'%H:%i')

4428 08:59

4429 08:59

4430 08:59

4431 08:59

相同数据只查询一条

SELECT `CpParkID` , `UPDATE_TIME` FROM `cp_park` WHERE `CpParkID` IN (SELECT MAX(`CpParkID`) FROM `cp_park`WHERE HOUR( `UPDATE_TIME` ) = '08'AND MINUTE( `UPDATE_TIME` ) = '59'group by UPDATE_TIME)