Mega Code Archive

 
Categories / MySQL Tutorial / Logic Operator
 

Logical OR (OR( ))

When both operands are non-NULL, the result is 1 if any operand is non-zero, and 0 otherwise. With a NULL operand, the result is 1 if the other operand is non-zero, and NULL otherwise. If both operands are NULL, the result is NULL. mysql> mysql> SELECT 1 || 1; +--------+ | 1 || 1 | +--------+ |      1 | +--------+ 1 row in set (0.00 sec) mysql> SELECT 1 || 0; +--------+ | 1 || 0 | +--------+ |      1 | +--------+ 1 row in set (0.00 sec) mysql> SELECT 0 || 0; +--------+ | 0 || 0 | +--------+ |      0 | +--------+ 1 row in set (0.00 sec)