N
N
Nick Bukovskiy2018-02-28 14:28:07
MySQL
Nick Bukovskiy, 2018-02-28 14:28:07

How to write a request correctly? Is an investment required?

it is necessary to select the data for today and for yesterday from the table for each id. I understand how to do this with two requests, but how can I merge it into one? Tell me please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Bobkov, 2018-02-28
@mike_bma

Put the condition through OR.

A
Andrey Tsvetkov, 2018-02-28
@yellow79

Something like this

SELECT 
    ... 
WHERE 
    DATE(`date`) >= DATE(DATE_SUB(NOW(), INTERVAL 1 DAY)) 
GROUP BY DATE(`date`)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question