how to ignore a condition in where clause

前端 未结 1 958
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-25 05:11

SELECT field1 FROM table1 WHERE field1 >= 4006 AND field1 < ( SELECT field1 FROM table WHERE field1 > 4006 AND field2 = fals

1条回答
  •  执念已碎
    2021-01-25 05:56

    Something like (untested!):

    SELECT field1 FROM table1
    WHERE field1 >= 4006 
      AND (field1 < (
        SELECT field1 
        FROM table
        WHERE field1 > 4006
              AND field2 = false
        ORDER BY field1 
        LIMIT 1
        )
        OR
        NOT EXISTS (
        SELECT field1 
        FROM table
        WHERE field1 > 4006
              AND field2 = false
        ORDER BY field1 
        )
    )
    

    0 讨论(0)
提交回复
热议问题