SQL Operators - GeeksforGeeks
SQL Operators - GeeksforGeeks
SQL Operators
SQL Operators perform arithmetic, comparison, and logical operations to manipulate and
retrieve data from databases.
In this article, we will discuss Operators in SQL with examples, and understand how they
work in SQL.
Operators in SQL
Operators in SQL are symbols that help us to perform specific mathematical and logical
computations on operands. An operator can either be unary or binary.
The unary operator operates on one operand, and the binary operator operates on two
operands.
Arithmetic operator
Comparison operator
Logical operator
Bitwise Operators
Compound Operators
Operator Description
https://www.geeksforgeeks.org/sql-operators/ 1/9
11/26/24, 11:56 AM SQL Operators - GeeksforGeeks
Operator Description
/ This operator works with the ‘ALL’ keyword and it calculates division
operations.
Query:
Output:
Operator Description
= Equal to.
https://www.geeksforgeeks.org/sql-operators/ 2/9
11/26/24, 11:56 AM SQL Operators - GeeksforGeeks
Operator Description
Query:
Output:
Operator Description
AND Logical AND compares two Booleans as expressions and returns true when
both expressions are true.
https://www.geeksforgeeks.org/sql-operators/ 3/9
11/26/24, 11:56 AM SQL Operators - GeeksforGeeks
Operator Description
NOT Not takes a single Boolean as an argument and change its value from false
to true or from true to false.
In this example, retrieve all records from the “employee” table where the “emp_city” column
is equal to ‘Allahabad’ and the “emp_country” column is equal to ‘India’.
Output:
Operator Description
| Bitwise OR operator
https://www.geeksforgeeks.org/sql-operators/ 4/9
11/26/24, 11:56 AM SQL Operators - GeeksforGeeks
Operator Description
Operator Description
https://www.geeksforgeeks.org/sql-operators/ 5/9
11/26/24, 11:56 AM SQL Operators - GeeksforGeeks
Operators
Description
ANY ANY compares a value to each value in a list of results from a query and
evaluates to true if the result of an inner query contains at least one row.
BETWEEN The SQL BETWEEN operator tests an expression against a range. The
range consists of a beginning, followed by an AND keyword and an end
expression.
EXISTS The EXISTS checks the existence of a result of a subquery. The EXISTS
subquery tests whether a subquery fetches at least one row. When no
data is returned then this operator returns ‘FALSE’.
SOME SOME operator evaluates the condition between the outer and inner
tables and evaluates to true if the final result returns any one row. If not,
then it evaluates to false.
UNIQUE The UNIQUE operator searches every unique row of a specified table.
In this example, we will retrieve all records from the “employee” table where the “emp_id”
column has a value that falls within the range of 101 to 104 (inclusive).
https://www.geeksforgeeks.org/sql-operators/ 6/9
11/26/24, 11:56 AM SQL Operators - GeeksforGeeks
Output:
SQL Operators
Similar Reads
Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
Structured Query Language (SQL): Structured Query Language (SQL) has a specific design
motive for defining, accessing and changement of data. It is considered as non-procedural,
In that case the important elements and its results are first specified without taking care of
the how they are computed. It is implemented over the database which is drive
2 min read
In this article, we will learn how to configure SQL jobs in SQL Server using T-SQL. Also, we
will discuss the parameters of SQL jobs in SQL Server using T-SQL in detail. Let's discuss it
one by one. Introduction :SQL Server Agent is a component used for database task
automation. For Example, If we need to perform index maintenance on Production ser
7 min read
Prerequisite: Basic Select statement, Insert into clause, Sql Create Clause, SQL Aliases We
can use various Arithmetic Operators on the data stored in the tables. Arithmetic Operators
are: + [Addition] - [Subtraction] / [Division] * [Multiplication] % [Modulus] Addition (+) : It is
used to perform addition operation on the data items, items include
5 min read
https://www.geeksforgeeks.org/sql-operators/ 7/9
11/26/24, 11:56 AM SQL Operators - GeeksforGeeks
SQL logical operators are used to test for the truth of the condition. A logical operator like the
Comparison operator returns a boolean value of TRUE, FALSE, or UNKNOWN. In this
article, we will discuss different types of Logical Operators. Logical operators are used to
combine or manipulate the conditions given in a query to retrieve or manipulat
4 min read
SQL Comparison Operators
SQL Comparison Operators are used to compare two values and check if they meet the
specific criteria. Some comparison operators are = Equal to, > Greater than , < Less than,
etc. Comparison Operators in SQLThe below table shows all comparison operators in SQL :
OperatorDescription=The SQL Equal Operator checks if the values of two operands ar
3 min read
SQL AND and OR operators are used for data filtering and getting precise results based on
conditions. They are used with the WHERE clause and are also called conjunctive operators.
The AND operator returns records where all conditions specified are true and the OR
operator returns records where at least one condition specified is true. AND and OR o
3 min read
An Input Parameter can influence the subset of rows it returns from a select statement within
it. A calling script can get the value of an output parameter. An aggregate function or any
computational expression within the stored process can be used to determine the value of
the output parameter. A parameter whose value is given into a stored proced
3 min read
1. Transact SQL (T-SQL) : T-SQL is an abbreviation for Transact Structure Query Language.
It is a product by Microsoft and is an extension of SQL Language which is used to interact
with relational databases. It is considered to perform best with Microsoft SQL servers. T-SQL
statements are used to perform the transactions to the databases. T-SQL has
3 min read
https://www.geeksforgeeks.org/sql-operators/ 8/9
11/26/24, 11:56 AM SQL Operators - GeeksforGeeks
In SQL we can retrieve data from multiple tables also by using SELECT with multiple tables
which actually results in CROSS JOIN of all the tables. The resulting table occurring from
CROSS JOIN of two contains all the row combinations of the 2nd table which is a Cartesian
product of tables. If we consider table1 contains m rows and table2 contains n
3 min read
How to Execute SQL Server Stored Procedure in SQL Developer?
A stored procedure is a set of (T-SQL ) statements needed in times when we are having the
repetitive usage of the same query. When there is a need to use a large query multiple times
we can create a stored procedure once and execute the same wherever needed instead of
writing the whole query again. In this article let us see how to execute SQL Serv
2 min read
Practice Tags :
python
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
https://www.geeksforgeeks.org/sql-operators/ 9/9