Vi bruger 0 = 0
eller normalt 1 = 1
som en stub :
select *
from My_Table
where 1 = 1
Så når du skriver filtre, kan du gøre det ved at tilføje/kommentere enkelte linjer :
-- 3 filters added
select *
from My_Table
where 1 = 1
and (Field1 > 123) -- 1st
and (Field2 = 456) -- 2nd
and (Field3 like '%test%') -- 3d
Næste version vil f.eks. være med to filtre fjernet:
-- 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%')
Lad os nu gendanne 3d-filteret på en meget nem måde:
-- 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