I have a query where I filter a column based on a where
clause, like so:
select * from table where col = val
What value do I set for val
so that there is no filtering in the where
clause (in which case the where
clause is redundant)?
I have a query where I filter a column based on a where
clause, like so:
select * from table where col = val
What value do I set for val
so that there is no filtering in the where
clause (in which case the where
clause is redundant)?
2
Answers
It’s impossible.
You might instead use
None
is a common sentinel value,but feel free to use another.
Consider switching from
=
equality toLIKE
.Then a
%
wildcard will arrange for an unfiltered blind query.Pro:
col
, for values ofval
ending with a%
wildcard.Cons:
col
, and the revised SELECT can now return multiple rows.%
characters that are not at the end ofval
may disable the index, leading to unexpectedly long query times / result set sizes.If col can’t be null you can use col=col?