本文介绍了在特定条件下从指定行到某些行之间选择行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
假设我们有一个表(具有2个字段,分别为version
,compatible
),其数据如下:
Hi
let's think we have a table (with 2 fields those are version
,compatible
) with data as follow :
+-------+------+
| 0.1.1 | true |
+-------+------+
| 0.1.2 | false|
+-------+------+
| 0.1.3 | true |
+-------+------+
| 0.1.4 | true |
+-------+------+
| 0.1.5 | true |
+-------+------+
| 0.1.6 | false|
+-------+------+
| 0.1.7 | true |
现在我要从compatible = false
的上一行到compatible = false
的下一行中选择version = '0.1.3'
的所有行结果应为0.1.2
,0.1.3
,0.1.4
,0.1.5
我该怎么办?
now i want to select all rows where version = '0.1.3'
from prior row that compatible = false
to next row that compatible = false
result should be 0.1.2
, 0.1.3
, 0.1.4
, 0.1.5
how can i do that ?
推荐答案
SELECT version, compatible
FROM YourTable
WHERE version >= '0.1.3'
AND version < (SELECT version
FROM YourTable
WHERE version > '0.1.3'
AND compatible = 'false'
ORDER BY version
LIMIT 1)
ORDER BY version
这篇关于在特定条件下从指定行到某些行之间选择行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!