Blog_Banner_Asset
    Homebreadcumb forward arrow iconBlogbreadcumb forward arrow iconFull Stack Developmentbreadcumb forward arrow iconList of Operators In SQL [With Examples]

List of Operators In SQL [With Examples]

Last updated:
2nd May, 2021
Views
Read Time
6 Mins
share image icon
In this article
Chevron in toc
View All
List of Operators In SQL [With Examples]

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 

Ads of upGrad blog

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.

Explore Our Software Development Free Courses

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

OperatorOperationDescription
   
+ AdditionThis operator is used to add two given values
SubtractionTo subtract the two given values, we can use this operator
*MultiplicationIf we have to multiply the two given values, then we can use this operator
/DivisionTo divide the two given values, we can use the division operator
%ModulusThis 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.

Explore our Popular Software Engineering Courses

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:

OperatorOperationDescription
=Equal toTo compare the two values, we can use this operator.
Greater thanThis Boolean operator returns TRUE if the value of the left operand is greater than the right operand value.
Less thanThis Boolean operator returns TRUE if the value of the left operand is less than the right operand value.
<=Less than or Equal toThis 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 toThis Boolean operator returns TRUE if the value of the left operand is greater than or equal to the right operand value.
< > Or !=Not Equal toThis operator is used to check whether the two given values are equal to each other or not.
! >Not greater thanTo 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 thanTo 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:

OperatorWhere to Use the Operator?
ALLThis operator is used to compare some specific values to the rest of the values of any set.
ANYTo compare any specific value of a set to the rest of the values, we can use this operator.
INTo compare any specific value to the literals, we can use this operator.
BETWEENTo search any value within a given range, we can use this operator.
AND and ORThese operators are used to define multiple conditions in the WHERE clause.
NOTTo reverse the output of the logical operator, the NOT operator can be used.
LIKEIf we want to compare a pattern through wildcard operators, then we can use the LIKE operator.
SOMETo compare some of the values to any specific value,we can use the SOME operator.
EXISTSWe 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.

In-Demand Software Development Skills

Conclusion

Ads of upGrad blog

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.

Read our Popular Articles related to Software Development

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.

Profile

Rohan Vats

Blog Author
Software Engineering Manager @ upGrad. Passionate about building large scale web apps with delightful experiences. In pursuit of transforming engineers into leaders.

Frequently Asked Questions (FAQs)

1What is SQL?

SQL stands for Structured Query Language and is a programming language designed to retrieve and manipulate data stored in relational database management systems. SQL is a standard, language-independent programming language. A programmer uses Structured Query Language to communicate with the database, with or without the support of a database manager.

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

Relational database is a subset of a non-relational database. The relational database consists of tables with a primary key and other columns that comprise the rows. It is free of any redundant data and it can be joined and/or related. Non-relational database (or non-SQL database) uses a different approach. It doesn't use tables at all, it works on the concept of documents. It may have a tree structure or it may be a graph structure. Relational databases store data in tables, which are made of rows and columns, data is related and arranged to the other data with joins, indexes, constraints and keys. On the other hand, non-relational databases are not hierarchical as relational databases and they store data as documents. Non-relational databases are not using joins to relate data, they use references within the document.

3What are the applications of SQL?

There are very few computer languages that can beat the popularity of SQL in terms of nature and scope. The popular programming languages like C, C++, PHP, Perl, Python are designed for general purpose scripting and that is the sole reason for their popularity and the scope. However, in the case of SQL, it is a language designed for handling data in the form of tables, data structure and queries. The popularity of this language can be testified by the fact that it is included in almost every database product having different name as FoxPro SQL, Oracle SQL and MS SQL Server. Though this language includes a vast range of databases, it is not exactly the same. For instance, FoxPro SQL is a dialect of Sybase SQL, while Oracle SQL is a dialect of PostgreSQL language.

Explore Free Courses

Suggested Blogs

Top 7 Node js Project Ideas &#038; Topics
31545
Node.JS is a part of the famous MEAN stack used for web development purposes. An open-sourced server environment, Node is written on JavaScript and he
Read More

by Rohan Vats

05 Mar 2024

How to Rename Column Name in SQL
46899
Introduction We are surrounded by Data. We used to store information on paper in enormous file organizers. But eventually, we have come to store it o
Read More

by Rohan Vats

04 Mar 2024

Android Developer Salary in India in 2024 [For Freshers &#038; Experienced]
901298
Wondering what is the range of Android Developer Salary in India? Software engineering is one of the most sought after courses in India. It is a reno
Read More

by Rohan Vats

04 Mar 2024

7 Top Django Projects on Github [For Beginners &amp; Experienced]
51981
One of the best ways to learn a skill is to use it, and what better way to do this than to work on projects? So in this article, we’re sharing t
Read More

by Rohan Vats

04 Mar 2024

Salesforce Developer Salary in India in 2024 [For Freshers &#038; Experienced]
909119
Wondering what is the range of salesforce salary in India? Businesses thrive because of customers. It does not matter whether the operations are B2B
Read More

by Rohan Vats

04 Mar 2024

15 Must-Know Spring MVC Interview Questions
34720
Spring has become one of the most used Java frameworks for the development of web-applications. All the new Java applications are by default using Spr
Read More

by Arjun Mathur

04 Mar 2024

Front End Developer Salary in India in 2023 [For Freshers &#038; Experienced]
902367
Wondering what is the range of front end developer salary in India? Do you know what front end developers do and the salary they earn? Do you know wh
Read More

by Rohan Vats

04 Mar 2024

Method Overloading in Java [With Examples]
26128
Java is a versatile language that follows the concepts of Object-Oriented Programming. Many features of object-oriented programming make the code modu
Read More

by Rohan Vats

27 Feb 2024

50 Most Asked Javascript Interview Questions &#038; Answers [2024]
4327
Javascript Interview Question and Answers In this article, we have compiled the most frequently asked JavaScript Interview Questions. These questions
Read More

by Kechit Goyal

26 Feb 2024

Schedule 1:1 free counsellingTalk to Career Expert
icon
footer sticky close icon