Loading

SQL Operators

  • SQL operators are keywords used to perform data operations in a relational database. 

Types of SQL Operators

  1. SQL Arithmetic Operators.
  2. SQL Comparison Operators.
  3. SQL Logical Operators.
  4. SQL Set Operators.
  5. SQL Unary operators.
  6. SQL Bitwise Operators.

Arithmetic operators :

  • The SQL Arithmetic Operator performs arithmetic computations and operations on the two operands or the numerical data in the database tables.
OperatorDescription
+

The Addition operators are used 

to perform addition operation on operands.

-

The Subtraction operators are used 

to perform Subtraction operation on operands.

*

The Multiplication operators are used 

to perform  Multiplication operation on operands

/

The Division operators are used 

to perform Division operation on operands.

%

The Modulus operators are used 

to perform Modulus operation on operands.


Example:

Let us consider student tables having 3 columns namely student ID, Physics(marks in physics), and Chemistry(marks in Chemistry):

ID

Physics

Chemistry

101

86

92

102

85

91

103

73

98

Now, let us perform some arithmetic operations using arithmetic operators.

SELECT Physics + Chemistry as Total _Marks 
FROM student;

Output:

Total_ Marks
178
176
171
  • In this query, we have added the Physics and Chemistry marks as the total marks.