## • NOT , ! 

Logical NOT. Evaluates to 1  if the operand is 0 , to 0  if the operand is nonzero, and NOT NULL  returns NULL . 

mysql> SELECT NOT 10; -> 0 mysql> SELECT NOT 0; -> 1 mysql> SELECT NOT NULL; -> NULL mysql> SELECT ! (1+1); -> 0 mysql> SELECT ! 1+1; -> 1 

The last example produces 1  because the expression evaluates the same way as (!1)+1 . 

The ! , operator is a nonstandard MySQL extension. As of MySQL 8.0.17, this operator is deprecated; expect it to be removed in a future version of MySQL. Applications should be adjusted to use the standard SQL NOT  operator. 

## • AND , && 

Logical AND. Evaluates to 1  if all operands are nonzero and not NULL , to 0  if one or more operands are 0 , otherwise NULL  is returned. 

mysql> SELECT 1 AND 1; -> 1 mysql> SELECT 1 AND 0; -> 0 mysql> SELECT 1 AND NULL; -> NULL mysql> SELECT 0 AND NULL; -> 0 mysql> SELECT NULL AND 0; -> 0 

The && , operator is a nonstandard MySQL extension. As of MySQL 8.0.17, this operator is deprecated; expect support for it to be removed in a future version of MySQL. Applications should be adjusted to use the standard SQL AND  operator. 

## • OR , || 

Logical OR. When both operands are non- NULL , the result is 1  if any operand is nonzero, and 0 otherwise. With a NULL  operand, the result is 1  if the other operand is nonzero, and NULL  otherwise. If both operands are NULL , the result is NULL . 

mysql> SELECT 1 OR 1; -> 1 mysql> SELECT 1 OR 0; -> 1 mysql> SELECT 0 OR 0; -> 0 mysql> SELECT 0 OR NULL; -> NULL mysql> SELECT 1 OR NULL; 

