An operator is a symbol which is used to perform some action on given expressions.
- Arithmetic Operators
- Logical Operators
- Set Operators
- Comparison Operators
- Special Operators
- Assignment Operators
- String Concat Operator
Arithmetic Operators
Arithmetic Operators are used for performing the mathematical operations on the given values.
Arithmetic Operators are used for performing the mathematical operations on the given values.
| Operator | Meaning |
| + | Add |
| - | Subtraction |
| * | Multiplication |
| / | Divide |
| % | Modulo |
Create a Table with a Name student.
- create Table student(id int,name varchar(50),Eng int,hindi int,math int,totalmarks int,avg int)
- insert into student(id,name,Eng,hindi,math)values(1,'A',65,58,49)
- insert into student(id,name,Eng,hindi,math)values(2,'B',45,33,41)
- insert into student(id,name,Eng,hindi,math)values(3,'C',65,88,35)
- insert into student(id,name,Eng,hindi,math)values(4,'D',61,88,62)
- insert into student(id,name,Eng,hindi,math)values(5,'E',41,81,81)
Example - Write a query to find total marks and average marks of a student
Total marks
- Update student set Totalmarks =Eng+hindi+math
Avg Marks
- update student set avg=Totalmarks /3
Select * from student
In the same manner, we can use others Arithmetic operators like -,*, %.
Assignment operator
The assignment operator is used to assign values to operands.
Assignment operator: =
Example
Write a query to display student details whose id=4?

In the same manner, we can use others Arithmetic operators like -,*, %.
Assignment operator
The assignment operator is used to assign values to operands.
Assignment operator: =
Example
Write a query to display student details whose id=4?
- Select * from student where id=4
Result
Comparison Operators
Comparison Operators are used for comparing values with the given specific conditions.
Set Operators
It is used to combine the result of 2 or more tables as a single set of values.
These operators are <,>,<=,>=,!=
Example
Write a query to display student details whose avg marks are greater than 60.

Comparison Operators
Comparison Operators are used for comparing values with the given specific conditions.
Set Operators
It is used to combine the result of 2 or more tables as a single set of values.
These operators are <,>,<=,>=,!=
Example
Write a query to display student details whose avg marks are greater than 60.
- select * from student where avg>60
Set Operators
It is used to combine the result of 2 or more Tables as a single set of values.
Type of Set Operators
- Union
- Union All
- Intersect
- Except
Some important Rules we should follow to use Set Operators
- Number of columns and order must be the same in all the queries.
- Columns Datatypes should be compatible.
Create two Tables
- Create table class_A(id int,studnetname varchar(50),Marks int,Age int)
- Create table class_B(id int,studentname varchar(50),marks int ,Age int)


Upendra Pratap ShahiPosted Sep 6, 2018, 6:45 AM
Nice one.......................