开发者

Select rows between an specified row to some row with particular condition

开发者 https://www.devze.com 2023-02-22 02:53 出处:网络
Hi let\'s think we have a table (with 2 fields those are version,compatible) with data as follow : +-------+------+

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开发者_如何转开发 |  

now i want to select all rows where version = '0.1.3' from prior row that compatible = falseto 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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号