Bangladesh University of Business of Technology
Lab Report 01
Name: Tanjida Akther Barakah
ID: 21225103203
Section: 05
Intake: 49
Course Code: 417
Submit To: Sayefa Arafah
Designation: Lecturer
Topic Name: SQLOperators
Description: SQL (Structured Query Language) operators are used to perform operations on data within
a database. SQL (Structured Query Language) operators help you work with data in a database. They let
you perform tasks like calculations, comparisons, and logical checks. Here are some common :
1. Arithmetic Operators: Perform basic mathematical operations like addition(+),subtraction(-
),multiplication(*),and division(/).
2. Comparison Operators: Compare two values (e.g., =, <>, >, <, >=, <=).
3. Logical Operators: Combine multiple conditions (e.g., AND, OR, NOT).
4. Set Operators: Combine results of two or more queries (e.g., UNION,
INTERSECT).
General Structure & Examples of SQL Operators:
● Arithmetic Operators:
Add ( + ):
Syntex: SELECT num1 + num2
Example: SELECT 30 + 20
Subtraction (- ):
Syntex: SELECT num1- num2
Example: SELECT 80-26
Multiply ( * ):
Syntex: SELECT num1 * num2
Example: SELECT 51 * 2
Division ( / ) :
Syntex: SELECT num1 / num2
Example: SELECT 62 / 4
Modulo ( % ):
Syntex: SELECT num1 % num2
Example: SELECT 56 % 2
● Comparison Operators:
Equal to ( = ) :
Syntex: SELECT * FROM table_name WHERE colum_name = value
Example: DELETE FROM `tanjida` WHERE Age=22
Greater Than ( > ) :
Syntex: SELECT * FROM table_name WHERE colum_name > value
Example: SELECT * FROM `tanjida` WHERE Salary>70000
Less Than ( < ) :
Syntex: SELECT * FROM table_name WHERE colum_name < value
Example: SELECT * FROM `tanjida` WHERE Salary<90000
Greater Than or Equal ( >= ) :
Syntex: SELECT * FROM table_name WHERE colum_name >= value
Example: SELECT * FROM `tanjida` WHERE Salary>=56000
Less Than or Equal ( <= ) :
Syntex: SELECT * FROM table_name WHERE colum_name <= value
ExampleSELECT * FROM `tanjida` WHERE Salary<=56000
Not Equal ( <> ) :
Syntex: SELECT * FROM table_name WHERE colum_name <> value
Example: SELECT * FROM `tanjida` WHERE Salary<>50000
● Logical Operators:
AND:
Syntex: SELECT * FROM table_name WHERE colum_name1 > value
ANDcolum_name2 = value
Example: SELECT * FROM `tanjida` WHERE Location='Usa' AND Age>21
OR :
Syntex: SELECT * FROM table_name WHERE colum_name1 > value
OR colum_name2 = value
Example: SELECT * FROM `tanjida` WHERE Location='Usa' AND Age>21
LIKE :
Syntex: SELECT * FROM table_name WHERE colum_name LIKE ‘%L’
ExampleSELECT * FROM `tanjida` WHERE Name LIKE '%k%'
NOT LIKE :
Syntex: SELECT * FROM table_name WHERE colum_name NOT LIKE
‘%C’
Example:SELECT * FROM `tanjida` WHERE Name NOT LIKE 'T%'
BETWEEN:
Syntax:SELECT * FROM TABLE_NAME
WHERE Column BETWEEN Value1 AND Value2;
Example:SELECT * FROM tanjida
WHERE Salary BETWEEN 60000 AND 100000;
● Set Operators:
UNION:
Syntex: SELECT column_name(s) FROM table1
UNION
SELECT column_name(s) FROM table2;
Example: SELECT Name FROM 'tanjida' UNION SELECT
Name FROM barakah;
INTERSECT:
Syntex: SELECT column_name(s) FROM table1 INTERSECT SELECT
column_name(s) FROM table2
Example: SELECT Name FROM tanjida INTERSECT SELECT
Name FROM barakah;