I recently discovered a statement in my code where I built up a MySQL statement that looks like the following:
select * from atable where col = 1 = 0
I was surprised that this actually is valid syntax - treated like "col = 0". I would 开发者_如何学Clike to understand why this is valid syntax and why the statement like this is not rejected. It certainly appears to be confusing, yet I just stumbled over it in logging execution, so I would never have known it was being generated otherwise. Is there a specific purpose in this format that I am missing?
It is same as col != 1
. It checks that col = 1
is false.
精彩评论