Jump to: navigation, search

Mysql OPERATOR EQUAL TO

From w3cyberlearnings

Contents

MySQL NULL-Safe Equal <=>

This operator performs an equality comparison like the = operator, but returns 1 rather than NULL if both operands are NULL, and 0 rather than NULL if one operand is NULL.

Syntax

N1 <=> N2;

Example 1

mysql> SELECT 3 <=> 3, NULL <=> NULL, 3 <=> NULL;
+---------+---------------+------------+
| 3 <=> 3 | NULL <=> NULL | 3 <=> NULL |
+---------+---------------+------------+
|       1 |             1 |          0 | 
+---------+---------------+------------+
1 row in set (0.00 sec)

Example 2


mysql> SELECT 3 <=> 3, 3 = 3, NULL <=> 3, NULL = 3;
+---------+-------+------------+----------+
| 3 <=> 3 | 3 = 3 | NULL <=> 3 | NULL = 3 |
+---------+-------+------------+----------+
|       1 |     1 |          0 |     NULL | 
+---------+-------+------------+----------+
1 row in set (0.00 sec)

Related Links



Navigation
Web
SQL
MISC
References