ID EN
Logical Operators

OR

MySQL 8.4

OR, ||

Syntax

MYSQL
SELECT 1 OR 1;
1
SELECT 1 OR 0;
1
SELECT 0 OR 0;
0
SELECT 0 OR NULL;
NULL
SELECT 1 OR NULL;
1

Examples

Example

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
SELECT 1 OR 0;
1
SELECT 0 OR 0;
0
SELECT 0 OR NULL;
NULL
SELECT 1 OR NULL;
1