Usamos 0 = 0
o, normalmente, 1 = 1
como un talón :
select *
from My_Table
where 1 = 1
Entonces, cuando escriba filtros, puede hacerlo agregando/comentando líneas individuales :
-- 3 filters added
select *
from My_Table
where 1 = 1
and (Field1 > 123) -- 1st
and (Field2 = 456) -- 2nd
and (Field3 like '%test%') -- 3d
La próxima versión, por ejemplo, tendrá dos filtros eliminados:
-- 3 filters added, 2 (1st and 3d) removed
select *
from My_Table
where 1 = 1
-- and (Field1 > 123) -- <- all you need is to comment out the corresponding lines
and (Field2 = 456)
-- and (Field3 like '%test%')
Ahora vamos a restaurar el filtro 3D de una manera muy sencilla:
-- 3 filters added, 2 (1st and 3d) removed, then 3d is restored
select *
from My_Table
where 1 = 1
-- and (Field1 > 123)
and (Field2 = 456)
and (Field3 like '%test%') -- <- just uncomment