SQL ordered filtering from multiple columns -
i have table below, being used both mysql , sqlite, sorted columns a, b, c in ascending order: # | | b | c -------------------------- 0 | 40 | 55 | blue 1 | 60 | 65 | red 2 | 60 | 65 | rose 3 | 60 | 65 | yellow 4 | 80 | 21 | green 5 | 85 | 12 | blue i want figure out "next" row after given row. example, if i'm looking @ row #2: a=60, b=65, c="rose" i want able figure out row #3 next 1 (i don't have # ids use in case). my naive approach this: select * table (a >= 60 , b >= 65 , c > "rose") or (a >= 60 , b > 65) or (a > 60) order a, b, c asc limit 1 is there better way this? thanks exclusive branches only slight change... think >= can = : select * table (a = 60 , b = 65 , c > "rose") or (a = 60 , b > 65) or (a > 60) order a, b, c asc limit 1 ids don't help you can add ...