0
我有一個包含timestamp列的表。對於給定的日期時間,我希望返回與給定分鐘相匹配的所有記錄,而不管它是在給定秒還是之後。MySQL select date分鐘匹配
換句話說,我有:
2017-04-01 09:41:23
2017-04-02 09:41:02
2017-04-02 09:41:27
2017-04-02 09:42:49
,並提供:
2017-04-02 09:41:30
我希望返回:
2017-04-02 09:41:02
2017-04-02 09:41:27
感謝所有幫助
你嘗試過什麼到目前爲止? – JYoThI
SELECT * FROM myTable WHERE updated BETWEEN $ time - INTERVAL 1 MINUTE ORDER BY updated DESC – Adry
use DATE_FORMAT and omit the seconds SELECT * FROM myTable where DATE_FORMAT(updated,'%Y-%m-%d%H:%i') = DATE_FORMAT('2017-04-02 09:41:30','%Y-%m-%d%H:%i') – JYoThI