SQL Operators
- SQL operators are keywords used to perform data operations in a relational database.
Types of SQL Operators
- SQL Arithmetic Operators.
- SQL Comparison Operators.
- SQL Logical Operators.
- SQL Set Operators.
- SQL Unary operators.
- 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.
Operator | Description |
---|---|
+ | 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.