Answer the question
In order to leave comments, you need to log in
How to pull the first records from the table by timestamp?
There is a table items
there are such fields
id | item_id | order_id | datetime
For an example I will give such 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 of order_id=10300, where the smallest datetime value and +5 seconds are taken.
Thus, I will pull out records 101 and 102
Is it possible to do this on the MySQL side?
Answer the question
In order to leave comments, you need to log in
SELECT * FROM items
WHERE order_id = 10300 AND datetime <= (
SELECT MIN(datetime) FROM items
WHERE order_id = 10300
) + 5
I understand you need something like this:
let items = (recoupment > 0 && await getItems(id, price, true)) || await getItems(id, price, false);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question