Mysql
 sql >> Database >  >> RDS >> Mysql

come ignorare una condizione in cui la clausola

Qualcosa come (non testato!):

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 
    )
)