DELETE FROM shipment WHERE last_update <= '2015-03-20 10:00:00' SET GLOBAL net_read_timeout = 120; -------------------------------------------------------------------------------------------- SELECT MAX(id) as max_id FROM `shipment` WHERE id >= 112000000000 and id <= 112009999999; -------------------------------------------------------------------------------------------- SELECT bh.`timestamp` AS record_time, s.id AS `shipment_id` FROM `box_history` bh LEFT JOIN box b ON b.id=bh.box_id LEFT JOIN shipment s ON b.shipment_id=s.id WHERE bh.`timestamp`>='2016-01-19 06:34:00' AND bh.`timestamp`<='2016-01-19 06:40:00' AND bh.synchro_office=1005 GROUP BY s.id ORDER BY bh.`timestamp`;