L
L
Leonid Fedotov2016-02-20 00:03:58
MySQL
Leonid Fedotov, 2016-02-20 00:03:58

How to get the value of a cell column into a variable from a selection in order to conditionally get a new selection with it?

There is a database of the form:
id value
1 0.1
2 0.4
3 0.7
4 0.1
5 0.2
It is necessary to make a complex select so that, in accordance with the condition (between two numbers), certain rows are selected, their id is obtained from them, and the next row is checked, after that id with the same condition. In the end, only those rows should be returned whose neighbors by id satisfy all the rules.
Is it possible to do this with just one MySQL query? 0_o

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2016-02-20
@iLeonidze

If the ids are strictly in order and there are no gaps, then you can try this:
select id, value from table where id in (select id+1 from table where value > 10 and value < 20) and value > 10 and value < 20

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question