How to use Relational Operators in MySQL
Notes:
How to use Relational Operators in MySQL:
Relational operators are also known as comparison operators. They are used to find the relationship between two values or compare the relationship between two values; on comparison they yield the result either 1 or 0. In MySQL; 1 indicates true and 0 indicates false vice versa.
< : less than
> : greater than
<= : less than or equal to
>= : greater than or equal to
!= or <>: not equal to
= : equal to
<=> : null safe equal to
Example Code:
select 3 < 4; // 1
select 5 < 4; // 0
select 5 > 4; // 1
select 5 > 6; // 0
select 5 <= 6; // 1
select 6 <= 6; // 1
select 7 <= 6; // 0
select 7 >= 6; // 1
select 7 >= 7; // 1
select 7 >= 8; // 0
select 7 != 7; // 0
select 7 != 8; // 1
select 7 <> 7; // 0
select 7 <> 8; // 1
select 7 = 8; // 0
select 7 = 7; // 1
select 7 <=> null; // 0
select null <=> null; // 1
Interview Questions: