W
W
WebGuardMan2015-10-25 13:16:34
MySQL
WebGuardMan, 2015-10-25 13:16:34

How to generate mySQL query?

There is a table of orders with fields
date
status
client id
, you need to select all records with status 0 whose date is less than the date of the last successful client order (status 1)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Martyanov, 2015-10-25
@WebGuardMan

SELECT * FROM table WHERE client_id = id AND status = 0 AND date < (SELECT date FROM table WHERE client_id = id AND status = 1 ORDER BY date LIMIT 1) - something like that, I think.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question