1
Is having a certain dispute whether or not the use of 1=1 in the where
of a query in my team.
Using this method to generate querys dynamically brings some harm in query performance or it does not influence?
1
Is having a certain dispute whether or not the use of 1=1 in the where
of a query in my team.
Using this method to generate querys dynamically brings some harm in query performance or it does not influence?
Browser other questions tagged sql
You are not signed in. Login or sign up in order to post.
Why use WHERE 1 = 1 in an SQL query?
– rray
Perhaps it has already been answered in the question linked by rray. But you could edit the question and put more context, real example of use to see if the question is not duplicate the other.
– Maniero
If you use a
join
to form the conditions with a vector will not be necessary1=1
, for in thejoin
a vector like this[1, 2, 3]
would result in this:1 AND 2 AND 3
, of course this is a very simple example.– Guilherme Nascimento
@rray I had already read this post, and it does not answer my question, my question was whether in performance the 1=1 is harmful, and yes I use the 1=1 to facilitate when putting the clauses in progress, so my question ñ was answered
– João
@João It’s not wrong but it’s ugly :-). With two lines more code SQL is sent to the bank only with what really matters. See the comment of Bacco in the answer of the linked question. As for performance, your database responds (analyze the execution plan of the two queries - at least in most banks will be equal).
– Caffé