Usiamo 0 = 0
o, di solito, 1 = 1
come tronco :
select *
from My_Table
where 1 = 1
Quindi, quando scrivi filtri puoi farlo aggiungendo/commentando singole righe :
-- 3 filters added
select *
from My_Table
where 1 = 1
and (Field1 > 123) -- 1st
and (Field2 = 456) -- 2nd
and (Field3 like '%test%') -- 3d
La prossima versione, diciamo, sarà con due filtri rimossi:
-- 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%')
Ora ripristiniamo il filtro 3d in modo molto semplice:
-- 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