Mysql
 sql >> Base de données >  >> RDS >> Mysql

comment ignorer une condition dans la clause where

Quelque chose comme (non testé !) :

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