How to select records from last 24 hours using SQL?

后端 未结 11 2160
Happy的楠姐
Happy的楠姐 2020-12-04 04:41

I am looking for a where clause that can be used to retrieve records for the last 24 hours?

11条回答
  •  余生分开走
    2020-12-04 05:22

    If the timestamp considered is a UNIX timestamp You need to first convert UNIX timestamp (e.g 1462567865) to mysql timestamp or data

    SELECT * FROM `orders` WHERE FROM_UNIXTIME(order_ts) > DATE_SUB(CURDATE(), INTERVAL 1 DAY)
    

提交回复
热议问题