0% found this document useful (0 votes)
9 views

SQL Operators: What Is SQL Operator?

The document discusses SQL operators which are used to perform operations in SQL queries. It covers unary and binary operators, and different types of operators like arithmetic, comparison, and logical operators. Examples are given showing how each operator is used in a SQL SELECT statement.

Uploaded by

Ahad Mohy Uddin
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

SQL Operators: What Is SQL Operator?

The document discusses SQL operators which are used to perform operations in SQL queries. It covers unary and binary operators, and different types of operators like arithmetic, comparison, and logical operators. Examples are given showing how each operator is used in a SQL SELECT statement.

Uploaded by

Ahad Mohy Uddin
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

SQL Operators

Every database administrator and user uses SQL queries for


manipulating and accessing the data of database tables and views.

The manipulation and retrieving of the data are performed with the
help of reserved words and characters, which are used to perform
arithmetic operations, logical operations, comparison operations,
compound operations, etc.

What is SQL Operator?


The SQL reserved words and characters are called operators, which are
used with a WHERE clause in a SQL query. In SQL, an operator can
either be a unary or binary operator. The unary operator uses only one
operand for performing the unary operation, whereas the binary
operator uses two operands for performing the binary operation.

Add Operator:
SELECT cust_name, opening_amt,
receive_amt, (opening_amt + receive_amt)
FROM customer
WHERE (opening_amt + receive_amt)>15000;

Subtract operator:
SELECT cust_name,opening_amt, payment_amt,
outstanding_amt
FROM customer
WHERE(outstanding_amt-payment_amt)=receive_amt;
Multiply operator:
SELECT agent_code, agent_name,
working_area, (commission*2)
FROM agents
WHERE (commission*2)>0.25;

Divide Operator:

SELECT cust_name, opening_amt, receive_amt,

outstanding_amt, (receive_amt*5/ 100) commission


FROM customer
WHERE outstanding_amt<=4000;

Medulo Operator:

SELECT 150%7

Comparison Operators:
SELECT *
FROM agents
WHERE commission = 0.15;
SELECT *
FROM agents
WHERE commission> 0.14;

SELECT *
FROM agents
WHERE commission >= 0.14;
SELECT *
FROM agents
WHERE commission <> 0.15;

Logical Operators
SELECT cust_code, cust_name,
cust_city,cust_country,grade
FROM customer
WHERE cust_country = 'UK' AND grade = 2;

SELECT cust_code,cust_name,
cust_city,cust_country,grade
FROM customer
WHERE cust_country = 'USA' OR grade = 3;

SELECT * FROM customer


WHERE NOT grade>1;
In the following topics, we are discussing the usage of multiple
AND operator.
SELECT cust_code,cust_name,cust_city,cust_country,grade
FROM customer
WHERE cust_country='UK'
AND cust_city='London' AND grade>1;

With AND OR:

SELECT cust_code, cust_name,


cust_city, cust_country, grade
FROM customer
WHERE (cust_country = 'UK'
OR cust_city = 'London')
AND grade <> 3;

You might also like