Explore Courses
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Birla Institute of Management Technology Birla Institute of Management Technology Post Graduate Diploma in Management (BIMTECH)
  • 24 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Popular
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science & AI (Executive)
  • 12 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
University of MarylandIIIT BangalorePost Graduate Certificate in Data Science & AI (Executive)
  • 8-8.5 Months
upGradupGradData Science Bootcamp with AI
  • 6 months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
OP Jindal Global UniversityOP Jindal Global UniversityMaster of Design in User Experience Design
  • 12 Months
Popular
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Rushford, GenevaRushford Business SchoolDBA Doctorate in Technology (Computer Science)
  • 36 Months
IIIT BangaloreIIIT BangaloreCloud Computing and DevOps Program (Executive)
  • 8 Months
New
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Popular
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
Golden Gate University Golden Gate University Doctor of Business Administration in Digital Leadership
  • 36 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
Popular
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
Bestseller
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
IIIT BangaloreIIIT BangalorePost Graduate Certificate in Machine Learning & Deep Learning (Executive)
  • 8 Months
Bestseller
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in AI and Emerging Technologies (Blended Learning Program)
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
ESGCI, ParisESGCI, ParisDoctorate of Business Administration (DBA) from ESGCI, Paris
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration From Golden Gate University, San Francisco
  • 36 Months
Rushford Business SchoolRushford Business SchoolDoctor of Business Administration from Rushford Business School, Switzerland)
  • 36 Months
Edgewood CollegeEdgewood CollegeDoctorate of Business Administration from Edgewood College
  • 24 Months
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with Concentration in Generative AI
  • 36 Months
Golden Gate University Golden Gate University DBA in Digital Leadership from Golden Gate University, San Francisco
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Deakin Business School and Institute of Management Technology, GhaziabadDeakin Business School and IMT, GhaziabadMBA (Master of Business Administration)
  • 12 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science (Executive)
  • 12 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityO.P.Jindal Global University
  • 12 Months
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (AI/ML)
  • 36 Months
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDBA Specialisation in AI & ML
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
New
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGrad KnowledgeHutupGrad KnowledgeHutAzure Administrator Certification (AZ-104)
  • 24 Hours
KnowledgeHut upGradKnowledgeHut upGradAWS Cloud Practioner Essentials Certification
  • 1 Week
KnowledgeHut upGradKnowledgeHut upGradAzure Data Engineering Training (DP-203)
  • 1 Week
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
Loyola Institute of Business Administration (LIBA)Loyola Institute of Business Administration (LIBA)Executive PG Programme in Human Resource Management
  • 11 Months
Popular
Goa Institute of ManagementGoa Institute of ManagementExecutive PG Program in Healthcare Management
  • 11 Months
IMT GhaziabadIMT GhaziabadAdvanced General Management Program
  • 11 Months
Golden Gate UniversityGolden Gate UniversityProfessional Certificate in Global Business Management
  • 6-8 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
IU, GermanyIU, GermanyMaster of Business Administration (90 ECTS)
  • 18 Months
Bestseller
IU, GermanyIU, GermanyMaster in International Management (120 ECTS)
  • 24 Months
Popular
IU, GermanyIU, GermanyB.Sc. Computer Science (180 ECTS)
  • 36 Months
Clark UniversityClark UniversityMaster of Business Administration
  • 23 Months
New
Golden Gate UniversityGolden Gate UniversityMaster of Business Administration
  • 20 Months
Clark University, USClark University, USMS in Project Management
  • 20 Months
New
Edgewood CollegeEdgewood CollegeMaster of Business Administration
  • 23 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
KnowledgeHut upGradKnowledgeHut upGradBackend Development Bootcamp
  • Self-Paced
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 5 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
upGradupGradUI/UX Bootcamp
  • 3 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
upGradupGradDigital Marketing Accelerator Program
  • 05 Months

SQL Operators & Their Types | SQL Operator Types

Updated on 18 November, 2022

10.58K+ views
10 min read

What are the Operators?

Every database admin or the geeks working on databases uses SQL queries to manipulate the data and retrieve the tables’ results. This manipulation of data is performed with the help of operators. An operator is a keyword used in SQL queries to manipulate the data, and it returns the results based on the functionality of that operator.

These operators allow us to perform multiple functionalities like performing arithmetic operations, comparing two expressions, etc. It generally also acts as a conjunction between multiple conditions in a query. The operators can either be unary operators or binary operators.

Unary operators use only one operand for their execution, whereas Binary operators use two operands. Operands are nothing but the objects on which we can use the operators. For example, consider the following statement: 1 + 2. Here 1 and 2 are the operands, whereas + is the operator. In SQL, instead of using only the numbers, we generally use tables to obtain the results. 

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

In this article, we shall look into the vast range of operators offered in SQL. After listing all the operators, we shall see a few examples for better understanding.

Type of Operators

The operators are categorized based upon their functionality. The types of operators are as follows: – 

Check out upGrad’s Advanced Certification in DevOps

1. Arithmetic Operators

Arithmetic operators are used to performing arithmetic operations like addition, subtraction, division, multiplication, etc. These operators generally take in numeric operands to manipulate the tables. The different operators that come under this category are as follows: – 

Operator Operation Description
+ Addition To add the values on either side of the operator.
Subtraction To subtract the right-hand operand from the left-hand operand
Multiplication To multiply the values on each side of the operator.
/ Division To divide the left-hand operand by the right-hand operand.
% Modulus To divide the left-hand operand by the right-hand operand and return the remainder.

2. Comparison Operators

Comparison operators are used to comparing the two operands and return the result based upon the comparison’s output. It will check if the row returns True or False for each row, and then it will return all the rows which match the criteria. The different operators that come under this category are as follows: – 

Check out upGrad’s Java Bootcamp.

Operator Operation Description
= Equal to It checks if the values of both the operands are equal or not. It will return the TRUE rows.
<> or != Not equal to It checks if the values of both the operands are equal or not. If they are not equal, then it will return TRUE.
> Greater than It checks if the value of the left operand is greater than the right operand or not.
< Less than It checks if the value of the left operand is less than the right operand or not.
!> Not greater than It checks if the left operand’s value is not greater than or equal to the right operand.
!< Not less than It checks if the left operand’s value is not less than or equal to the right operand or not.
>= Greater than or equal to It checks if the left operand’s value is greater than or equal to the right operand or not.
<= Less than or equal to It checks if the left operand’s value is less than or equal to the right operand or not.

3. Logical Operators

Logical operators are the boolean operators that take two expressions as operands and provide output as True or False. The expressions give output as True or False, and the logical operators are used to combine these expressions.

These operators come in handy when we are dealing with complex SQL queries. These operators perform similarly to what we know as logic gates. The different operators that come under this category are as follows: – 

Operator Description
ALL Returns the rows for which all of the subqueries meet the condition specified
AND Returns the rows for which all the conditions separated by AND return True
ANY Returns the rows for which any of the subqueries meet the condition
SOME Returns the rows for which any of the subqueries meet the condition
LIKE Returns the rows for which the operand matches a pattern
IN Returns the rows for which if the operand is equal to one of the lists of expressions
NOT Returns the rows for which the condition(s) is NOT TRUE
OR Returns the rows for which any of the conditions separated by OR is TRUE
BETWEEN Returns the rows for which the operand is within the range of comparisons
EXISTS Returns the rows for which the subquery returns one or more records
NULL Returns the rows where the operands are NULL.

4. Compound Operators

Compound operators are used to executing some operations and then set the original value to the query’s value. These operators are not available in some databases like SQLite. You can use them in T-SQL (Transact-SQL), which is an extension of SQL. The different operators that come under this category are as follows: –

Operator Description
+= Adds the value to the original value and sets the original value to the result.
-= Subtracts the value from the original value and sets the original value to the result.
*= Multiplies the original value by some value and sets the original value to the result.
/= Divides the original value by some value and sets the original value to the result.
%= Performs modulus and sets the original value to the result.
&= Performs Bitwise AND operation and sets the original value to the result.
^-= Performs Bitwise EX-OR operation and sets the original value to the result.
|*= Performs Bitwise OR operation and sets the original value to the result.

5. Bitwise Operators

Bitwise operators are used to performing bitwise manipulations between the two expressions containing integers. These operators first convert the integers into bits and then operate on each bit to obtain the result.

The result is then again converted into an integer format to provide the outcome. These operators are seldomly used in SQL queries. The different operators that come under this category are as follows: – 

Operator Description
& Used to perform bitwise AND operation
| Used to perform bitwise OR operation
^ Used to perform bitwise EX-OR operation

Also Read: Interesting SQL Projects on GitHub

6. Set Operators

Set operators are used when we want to merge multiple queries using different tables. You can refer to the Venn diagrams to better understand how these set operations exactly work. The different operators that come under this category are as follows: –

Operator Description
UNION This operator will perform the union of both expressions.
UNION ALL Similar in function to the union. The difference is this operator gives the result without removing any duplications.
INTERSECT This operator will display the rows which are present in both expressions.
MINUS This operator will display the rows present in the first expression but absent in the second expression.

Examples

For illustration purposes, we will refer to one table named ‘cities’ and demonstrate how the operators work using this table. The below image that consists of a set of records will help you understand how the table looks and its different columns.

7. Arithmetic Operations

Query: – SELECT latd + 2, latd – 2, latd * 2, latd / 2, latd % 2 FROM cities;

In this query, we have used arithmetic operators to showcase how they work on the columns. The arithmetic operators deal with the numeric type of data and provide output accordingly.

8. Comparison Operations

Query: – SELECT * FROM cities WHERE latm <= 20;

This query will show all the rows where late is less than or equal to 20. Similarly, according to your use case, we can use other logical operations like <, >, etc.according to your use-case.

9. Logical Operations

Query: – SELECT * FROM cities WHERE lats BETWEEN 20 AND 50;

This query will display all the rows where the ‘lats’ column’s value lies in the range of 20 to 50, including the end values.

10. Bitwise Operators

Query: – SELECT CAST(latd as bit) | ’11’ FROM Cities;

The above query will perform bitwise OR operation on the operands. First, we need to convert the integer data type to bit values. To achieve this, we make use of the cast function. This function can help you to convert a value into another data type.

Set Operators: 

Query: – 

SELECT and FROM Cities UNION SELECT name FROM demo;

This query will list all the land’s column’s values and ‘name’ column from ‘cities’ and ‘demo’ tables.

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

Conclusion

This article shed some light on what operators are in SQL and the different types of SQL operators. The list of operators mentioned here is not exhaustive. It may also happen that your database may not support some of the operators listed. For example, the operators shown in compound operators are supported in Transact-SQL, which is nothing but an SQL extension.

There can always be some alternate workarounds for performing such operations. Now with a huge amount of data being generated, SQL may not be an efficient solution for data of humungous sizes. Still, it acts as a great tool for storing different applications’ metadata and serving as a back-end database to these applications. 

If you’re interested to learn more about full-stack development, check out upGrad & IIIT-B’s Executive PG Program 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?

SQL stands for Structured Query Language. It is a database language that has been developed by IBM in the 70's and is used by most of the database technology providers like Oracle, MySQL, SQL Server and IBM. It is a standard language that is used to manipulate and retrieve data from any database. SQL is one of the most widely used database languages. SQL is the most widely used programming language in the world for getting data from relational databases. It does not care about the underlying data, but the structure of the data stored in a database. SQL is a programming language used to access databases. It can be used to create, read, write, update and delete information in the database.

2. What are operators in SQL?

In SQL, operators are used to perform arithmetic or string operation on variables. There are three types of operators in SQL: Arithmetic Operators, String Operators and Logical Operators. Operators are used in SQL to perform specific mathematical, logical or comparison operations on the records in a database. The comparison operators in SQL are equal to, less than, greater than, less than or equal to, greater than or equal to, not equal to and NULL. The mathematical operators are addition, subtraction, multiplication and division. The logical operators are AND and OR.

3. What are some of the most common commands in SQL?

Some common SQL commands are listed below. SELECT returns data from one or more tables. When used in combination with WHERE and ORDER BY, it retrieves specific data from a database. UPDATE allows you to modify records in a database. You can use it to change existing data or add new records. DELETE is used to remove records from a database. Many languages, such as PHP, include SQL database functions which allow you to write SQL statements and access a database without knowing the details of SQL.

RELATED PROGRAMS