MySQL Operators

These are the following mostly used MySQL operators -

Operator Name Description
AND, && Logical AND
BINARY Cast a string to binary string
& Bitwise AND
| Bitwise OR
^ Bitwise XOR
= Equal Operator
>= Greater than or equal operator
<= Less than or equal operator
< Greater than operator
> Less than operator
LIKE Simple Pattern Matching
NOT LIKE Negation of Simple Pattern Matching
NOT, ! Negates Value
|| Logical OR

Examples

These are the some operator examples. Suppose, we have students table as follows -

students table

Greater than
The given query returns all the students whose age are greater than 10.

SELECT * FROM students WHERE age > 10;
greater than

Less than
The given query returns all the students whose age are less than 11.

SELECT * FROM students WHERE age < 11;
less than

Greater than or equal operator
The given query returns all the student whose age are greater than or equals to 11.

SELECT * FROM students WHERE age >= 10;
greater than equal

LIKE operator
The given query returns all the students whose 'first_name' starts with 'j'.

SELECT * FROM students WHERE first_name LIKE 'j%';
like

Logical OR operator
The given query returns all those students either whose 'first_name' starts with 'j' or study in class '6C'.

SELECT * FROM students WHERE first_name LIKE 'j%' OR class = '6C';
like


Read more articles


General Knowledge



Learn Popular Language