开发者

Purpose of MySQL support for "where col = 1 = 0"?

开发者 https://www.devze.com 2023-04-08 20:00 出处:网络
I recently discovered a statement in my code where I built up a MySQL statement that looks like the following:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消