I encountered a piece of sql today that I can’t figure out, please help!
A mysql query statement:
select * from table where fielda='123' and not '456'
What does and not
mean?
I tried it myself select * from table where not '123'
can also be executed
How to understand?
代言2017-06-10 09:51:43
What a strange way of writing.
fielda='123' and not '456'
Breakdown:
fielda='123'
and
not '456'
Equivalent to:
fielda='123' and 0
Equivalent to:
select * from table where 0
(I don’t know if my priorities are right)
typecho2017-06-10 09:51:43
MySQL syntax logical operators:
If the following operand is 0, the value is 1; if the operand is non-0, the value is 0, and NULL is treated specially, that is, NOT NULL is NULL.