How to get the first record from the table based on the timestamp?

There is a table items
there are such fields
id | item_id | order_id | datetime

For example, such a structure

101 | 3154 | 10300 | 2019-08-02 14:50:10
102 | 1355 | 10300 | 2019-08-02 14:50:11
103 | 8554 | 10300 | 2019-08-02 14:56:31

104 | 1354 | 10301 | 2019-08-02 15:31:10
105 | 9457 | 10302 | 2019-08-02 15:40:10
106 | 8621 | 10302 | 2019-08-02 16:50:10
107 | 4521 | 10303 | 2019-08-02 17:20:10
108 | 3252 | 10300 | 2019-08-02 18:13:10
109 | 1357 | 10304 | 2019-08-02 19:50:10

I need to get all the elements order_id=10300, where the smallest value of datetime and +5 seconds
So pull records 101 and 102

Is it possible to do on the MySQL side?
March 25th 20 at 13:01
1 answer
March 25th 20 at 13:03
Solution
SELECT * FROM items 
WHERE order_id = 10300 AND datetime <= (
 SELECT MIN(datetime) FROM items 
 WHERE order_id = 10300
) + 5

Find more questions by tags SQLMySQL