MySQL MariaDB

MySQL Operators

This post will lay out the various types of operators that are supported in MySQL and describe what each operator does.

Let’s dive in.

MySQL Arithmetic Operators

As the name describes, arithmetic operators are used to performing arithmetic operations on various operands.

They include the following:

Operator Description Example
+ Addition operator a + b
Minus Operator a – b
%, mod Modulo Operator a % b, mod(a,b)
* Multiplication Operator a * b
/ Division Operator a / b

 

MySQL Comparison Operators

These types of operators are used to perform the Boolean comparison operations. They include the following:

Operator Description Example
= Equality Operator a = b
Greater than operator a > b
<  Less than operator a < b
>= Greater than or equal to operator a >= b
<= Less than or equal to operator a <= b
<>, != Not Equal operator a != b, a <> b

 

MySQL Bitwise Operators

Bitwise operators are used to perform the Bitwise operations on a set of operands. They include the following:

Operator Description Example
& Bitwise AND a & b
| Bitwise OR a | b
^ Bitwise Exclusive OR a ^ b
~ Bitwise inversion a ~ b

 

MySQL Compound Operators

Compound operators are used to perform a binary operation on a set of operands and store the result in the left operand.

These types of operators include:

Operator Description Example
+=  Compound Add operator a += b
-= Compound subtraction operator a -= b

*=
Compound multiplication operator a *= b
/= Compound division a /= b
%= Compound modulo a %= b
&= Compound bitwise AND equals operator a &= b
|*= Compound bitwise equals a |*= b
^-= Compound bitwise exclusive equals a ^-= b

 

MySQL Logical Operators

The logical operators are used to perform the logical comparisons.

Name Description
AND, && Logical AND
NOT, ! Negates value
OR, || Logical OR
XOR Logical XOR

 

Conclusion

This article outlines the most popular and valuable operators in the MySQL database. Feel free to explore the other documents for more information.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list