Useless combination of logical expressions
Recently I stumbled upon this SQL where clause :
To analyze why such combination are useless,
Lets define two variables to simplify things :
And draw it on one table :
Then I wonder, what good does that do ? It always evaluates to true..
It only make sense if we combine the status comparisons with the and operator :
status <> 2 OR status <> 0or in equivalent form for you PHP developers :
(status != 2 ) || (status != 0)
To analyze why such combination are useless,
Lets define two variables to simplify things :
A = (status <> 0)
B = (status <> 2)
And draw it on one table :
Then I wonder, what good does that do ? It always evaluates to true..
It only make sense if we combine the status comparisons with the and operator :
Comments