GNU Info

Info Node: (mysql.info)Logical Operators

(mysql.info)Logical Operators


Next: Control flow functions Prev: Comparison Operators Up: Non-typed Operators
Enter node , (file) or (file)node

Logical Operators
.................

All logical functions return `1' (TRUE), `0' (FALSE) or `NULL'
(unknown, which is in most cases the same as FALSE):

`NOT'
`!'
     Logical NOT. Returns `1' if the argument is `0', otherwise returns
     `0'.  Exception: `NOT NULL' returns `NULL':
          mysql> select NOT 1;
                  -> 0
          mysql> select NOT NULL;
                  -> NULL
          mysql> select ! (1+1);
                  -> 0
          mysql> select ! 1+1;
                  -> 1
     The last example returns `1' because the expression evaluates the
     same way as `(!1)+1'.

`OR'
`||'
     Logical OR. Returns `1' if either argument is not `0' and not
     `NULL':
          mysql> select 1 || 0;
                  -> 1
          mysql> select 0 || 0;
                  -> 0
          mysql> select 1 || NULL;
                  -> 1

`AND'
`&&'
     Logical AND. Returns `0' if either argument is `0' or `NULL',
     otherwise returns `1':
          mysql> select 1 && NULL;
                  -> 0
          mysql> select 1 && 0;
                  -> 0


automatically generated by info2www version 1.2.2.9