View All
View All
View All
View All
View All
View All
View All
View All
View All
View All
View All
View All
View All

List of Operators In SQL [With Examples]

By Rohan Vats

Updated on Nov 18, 2022 | 6 min read | 6.6k views

Share:

We have to perform several operations to retrieve or alter any existing data from the database. SQL offers several operators to perform database management system operations. Here through this article, we will discuss several SQL operators and some basic information and examples. Let us discuss operators in SQL now.

Check out our free courses to get an edge over the competition

What are Operators?

SQL Operators are like SQL keywords that can perform arithmetic, comparison, and logical operations. They are like conjunctions and can be used to specify the operations and conditions in SQL statements. They can serve multiple conditions in the statement like:

  • Arithmetic Operators
  • Logical Operators
  • Comparison Operators

Check out upGrad’s Advanced Certification in Cloud Computing 

As there are several types of operators in SQL  anyone can take any SQL course to learn more operators. Let us understand them with examples in the next section.

Operators in SQL

1. Arithmetic Operators

Arithmetic operators can be used to perform arithmetic operations that include addition, subtraction, multiplication, and division.

Check out upGrad’s Advanced Certification in Cyber Security

  Operator

Operator Operation Description
     
+ Addition This operator is used to add two given values
Subtraction To subtract the two given values, we can use this operator
* Multiplication If we have to multiply the two given values, then we can use this operator
/ Division To divide the two given values, we can use the division operator
% Modulus This operator returns the remainder obtained by dividing the two given values

Example of Arithmetic Operators in SQL:

SELECT 80 + 10;

SELECT 80 – 10;

SELECT 80 * 10;

SELECT 80 / 10;

SELECT 80 % 10;

The output of the above SQL commands with arithmetic operators will be:

90

70

800

8

0

So, these are the arithmetic operators of SQL. Let us now see the Comparison operators in SQL.

Coverage of AWS, Microsoft Azure and GCP services

Certification8 Months
View Program

Job-Linked Program

Bootcamp36 Weeks
View Program

2. Comparison Operators in SQL

Comparison operators are used to comparing the two values that may be either less than or greater than or equal to each other. The table of comparison operators is:

Operator Operation Description
= Equal to To compare the two values, we can use this operator.
Greater than This Boolean operator returns TRUE if the value of the left operand is greater than the right operand value.
Less than This Boolean operator returns TRUE if the value of the left operand is less than the right operand value.
<= Less than or Equal to This Boolean operator returns TRUE if the value of the left operand is less than or equal to the right operand value.
>= Greater than or Equal to This Boolean operator returns TRUE if the value of the left operand is greater than or equal to the right operand value.
< > Or != Not Equal to This operator is used to check whether the two given values are equal to each other or not.
! > Not greater than To check whether the left operand is greater than or not than the right operand and this operator returns TRUE if it is found the truth.
!< Not less than To check whether the left operand is less than or not than the right operand and this operator returns TRUE if it is found the truth.

To compare the logical values, these operators are used in SQL. Now let us discuss a few of the 

logical operators in SQL.

Example of “=”,”<” and “>” Operator

SELECT * FROM Employees WHERE Age = 20;

SELECT * FROM Employees WHERE Age < 20;

SELECT * FROM Employees WHERE Age > 20;

upGrad’s Exclusive Software Development Webinar for you –

SAAS Business – What is So Different?

3. Logical Operators in SQL

Let us now discuss the logical operators in SQL. There are few cases as specified in the following table where we can use these logical operators:

Operator Where to Use the Operator?
ALL This operator is used to compare some specific values to the rest of the values of any set.
ANY To compare any specific value of a set to the rest of the values, we can use this operator.
IN To compare any specific value to the literals, we can use this operator.
BETWEEN To search any value within a given range, we can use this operator.
AND and OR These operators are used to define multiple conditions in the WHERE clause.
NOT To reverse the output of the logical operator, the NOT operator can be used.
LIKE If we want to compare a pattern through wildcard operators, then we can use the LIKE operator.
SOME To compare some of the values to any specific value,we can use the SOME operator.
EXISTS We can use this operator to search the presence of any row in the table.

Example of BETWEEN and IN Operators

SELECT * FROM Employees WHERE Age BETWEEN 20 AND 40;

SELECT * FROM Employees WHERE Age IN (‘20’,‘ 40’);

These two queries are examples of SQL operators.

Related Read: SQL Project Ideas & Topics

Learn Software Development Courses online from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs, or Masters Programs to fast-track your career.

Conclusion

SQL has many uses and operators, and you can use and practice these operators to know more about them. SQL operators help in fast data processing. Moreover, to compare any two values, these operators can be directly used. The operators are being asked during many interviews of fresher and experienced candidates. Learning SQL commands and an operator can help you in clearing interviews.

If you’re interested to learn more about full-stack development, check out upGrad & IIIT-B’s Executive PG Programme in Full-stack Software Development which is designed for working professionals and offers 500+ hours of rigorous training, 9+ projects, and assignments, IIIT-B Alumni status, practical hands-on capstone projects & job assistance with top firms.

Frequently Asked Questions (FAQs)

1. What is SQL?

2. What is the difference between relational and non-relational database?

3. What are the applications of SQL?

Rohan Vats

408 articles published

Get Free Consultation

+91

By submitting, I accept the T&C and
Privacy Policy

India’s #1 Tech University

Executive PG Certification in AI-Powered Full Stack Development

77%

seats filled

View Program

Top Resources

Recommended Programs

upGrad

AWS | upGrad KnowledgeHut

AWS Certified Solutions Architect - Associate Training (SAA-C03)

69 Cloud Lab Simulations

Certification

32-Hr Training by Dustin Brimberry

View Program
upGrad

Microsoft | upGrad KnowledgeHut

Microsoft Azure Data Engineering Certification

Access Digital Learning Library

Certification

45 Hrs Live Expert-Led Training

View Program
upGrad

upGrad KnowledgeHut

Professional Certificate Program in UI/UX Design & Design Thinking

#1 Course for UI/UX Designers

Bootcamp

3 Months

View Program