Home  >  Q&A  >  body text

mysql syntax where abbreviation?

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?

迷茫迷茫2687 days ago1017

reply all(2)I'll reply

  • 代言

    代言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)

    reply
    0
  • 梦想成真

    and means that two conditions must be met

    梦想成真 · 2017-06-10 21:27:47
  • typecho

    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.

    reply
    0
  • Cancelreply