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

SQL_Operator_7

The document provides examples of SQL operations on a Products table, including arithmetic operations like addition, subtraction, multiplication, and division. It also covers comparison operators such as equal to, not equal, greater than, and less than, along with logical operators like AND, OR, and NOT. Additionally, it explains the use of IN, BETWEEN, LIKE, and EXISTS for filtering data in SQL queries.

Uploaded by

anshsinghas12664
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

SQL_Operator_7

The document provides examples of SQL operations on a Products table, including arithmetic operations like addition, subtraction, multiplication, and division. It also covers comparison operators such as equal to, not equal, greater than, and less than, along with logical operators like AND, OR, and NOT. Additionally, it explains the use of IN, BETWEEN, LIKE, and EXISTS for filtering data in SQL queries.

Uploaded by

anshsinghas12664
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

For instance, consider a Products table with the following data:

ProductID Price Quantity Cost


1 50 10 25
2 30 20 17
3 70 15 40

Opera Descript
Example
tor ion
+ Addition SELECT *, Cost + 5 as New_Cost FROM Products;
Subtracti
– SELECT *, Price - Cost as Proft FROM Products;
on
Multiplica
* SELECT *, Price * Quantity as Revenue FROM Products;
tion
/ Division SELECT *, Cost / Price as Cost_Price_Ratio FROM Products;
% Modulus SELECT *, Price % Cost as Price_Cost_Modulus FROM Products;
Opera Descripti
Example
tor on
= Equal to SELECT * FROM Products WHERE Price = 50;
<> Not equal
SELECT * FROM Products WHERE Price <> 50;
or != to
Greater
> SELECT * FROM Products WHERE Price > 50;
than
< Less than SELECT * FROM Products WHERE Price < 50;
Greater
>= than or SELECT * FROM Products WHERE Price >= 50;
equal to
Less than
<= or equal SELECT * FROM Products WHERE Price <= 50;
to
Opera Descripti
Example
tor on

True if all
AND condition SELECT * FROM Products WHERE Price > 20 AND Quantity < 10;
s are true

OR True if at SELECT * FROM Products WHERE Price < 20 OR Quantity > 10;
Opera Descript
Example
tor ion
least one
condition
is true

True if
the
NOT SELECT * FROM Products WHERE NOT Price = 30;
condition
is false

True if
the value
IN SELECT * FROM Products WHERE ProductID IN (1,2,3);
is in the
list

True if
BETW the value
SELECT * FROM Products WHERE Price BETWEEN 20 AND 30;
EEN is within
the range

True if
the value
LIKE matches SELECT * FROM Products WHERE ProductName LIKE 'A%';
the
pattern

True if
the
subquery SELECT * FROM Products WHERE
EXIST
returns EXISTS (SELECT ProductID FROM Inventory WHERE Products.Pro
S
at least ductID = Inventory.ProductID);
one
record

You might also like