Database management system - Assignment

Verified

Added on  2021/05/31

|34
|4683
|127
AI Summary

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
MIS - 401: Database Management System
Assignment on: SQL/MY SQL
Submitted To:
Dr. M. Helal Uddin Ahmed
Professor
Department of Management Information Systems
University Of Dhaka
Submitted By:
Shamima Iqbal
029-12-078
Section- B
Batch- 12
Department of Management Information Systems
University Of Dhaka
June 1, 2020
1 | P a g e

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
Dr. M. Helal Uddin Ahmed
Professor
Department of MIS
University of Dhaka
Subject: Submission of the report titled as ‘Structured Query Language’
Sir,
With Due respect and honor submit the report prepared for the course “Database
Management”. It reflects the concept of structured query language (SQL). I tried
to accommodate as much information and relative issues as possible. I would like
to thank you for providing me with this opportunity.
Sincerely yours
Shamima Iqbal
ID: 029-12-078
BBA 12th Batch, Section: B
Department of Management Information Systems
Faculty of Business Studies
University of Dhaka
Executive summary:
2 | P a g e
Document Page
Now-a-days, almost all businesses, from small online stores to Multinational
corporations use data to run their operations. They manage this data using
databases. Because of this, the demand for database administration experts has
exploded, and because of this demand, working as a database developer,
particularly an SQL developer can be very lucrative. This report shows a brief
summary of the some of the concepts and techniques that we’ve learned from the
W3schools MySQL tutorial and MySQL in the first few lectures given by our
course instructor. It is arranged in order by when the material is presented. It’s a
good learning that we’ve done and what we will do in the next day. We’ve learned
a basic tutorial from that web-based learning platform. We can develop our skills
in SQL/MySQL programming languages. It also contains several business
applications and their optimum solution by using MySQL programming syntax.
What Is SQL:
3 | P a g e
Document Page
SQL is used to perform multiple functions in a database, such as running queries,
updating and modifying records, creating views, and setting permissions. Many
significant commands are used in SQL, such as select, alter database, drop table,
drop index, update, delete, create table, create database, create index, insert into,
alter table, etc. All Relational Database Management Systems (RDMS) such as
MySQL, Sybase, MS Access, Informix, and SQL Server use SQL as their standard
language for databases. It can be used to accomplish almost everything that one
needs to do with a database.
What Is RDBMS
RDBMS stands for Relational Database Management System. RDBMS is the basis
for SQL, and for all modern database systems like MS SQL Server, Oracle, IBM
DB2, MySQL, and Microsoft Access. A Relational database management system
is a database management system that is based on the relational model.
What is Table?
The data in an RDBMS is stored in database objects which are called as tables.
This table is basically a collection of related data entries and it consists of
numerous columns and rows. Remember, a table is the most common and simplest
form of data storage in a relational database. The following program is an example
of a CUSTOMERS table
ID Name AGE Address Salary
1 Shamima 22 Dhaka 5000
2 Anik 23 Khulna 20000
4 | P a g e

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
3 Rafsan 23 Rajshahi 10000
4 Dia 22 Dhaka 7000
5 Arfana 25 Narayanganj 12000
6 Mahin 26 Cumilla 8000
7 Tasnim 28 Tangail 25000
What is a field?
Every table is broken up into smaller entities called fields. The fields in the
CUSTOMERS consist of ID, NAME, AGE, ADDRESS and SALARY. A field is a
column in a table that is designed to maintain specific information about every
record in the table.
What is a Record or a Row?
A record is also called as a row of data is each individual entry that exists in a
table. For example, there are 7 record in the above CUSTOMERS table. Following
is a single row of data or record in the CUSTOMERS table –
1 Shamima 22 Dhaka 5000
What is a column?
A column is a vertical entity in a table that contains all information associated
with a specific field in a table. For example, a column in the CUSTOMERS table is
ADDRESS, which represents location description and would be as shown below –
ID
1
2
3
4
5
5 | P a g e
Document Page
6
7
SQL Syntax
The syntax of a language describes the language elements. SQL statements are
somewhat like simple English sentences. Keywords include SELECT, UPDATE,
WHERE etc. SQL was designed to be entered on a console and results would
display back to a screen. Today, SQL is mostly used by programmers who use
SQL inside their language to build applications that access data in a database. Four
fundamental operations that apply to any database are: * Read the data -- SELECT
* Insert new data -- INSERT * Update existing data -- UPDATE * Remove data --
DELETE
The SQL Command General form:
**
SELECT column-names
FROM table-name
WHERE condition
ORDER BY sort-order
**
Example:
SELECT FirstName,
LastName, City, Country
FROM Customer
WHERE City = 'Dhaka'
ORDER BY FirstName
6 | P a g e
Document Page
*The SQL INSERT general form
INSERT table-name (columnames)
VALUES (column-values)
Example
INSERT CUSTOMER (Name,
ContactName, Country,City)
VALUES ('Randevo expo', 'Lina Sam',
'Bangladesh', Dhaka ')
* The SQL UPDATE general form:
UPDATE table-name
SET column-name = columnvalue
WHERE condition
Example
UPDATE Item
SET Quantity = 3
WHERE Id = 30
* The SQL DELETE general form:
DELETE table-name
WHERE condition
Example
DELETE ORDER
WHERE ID = 38
7 | P a g e

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
*SQL SELECT STATEMENT:
The SELECT statement retrieves data from a database.The data is returned in a
table-like structure called a result-set. SELECT is the most frequently used action
on a database.
*The SQL general SELECT syntax is:
SELECT column-names
FROM table-name
*Example:
SELECT *
FROM table-name
SQL SELECT Examples:
Problem: List all customers
SELECT * FROM Customer
Results: 91 records
ID F. NAME L.NAME CITY COUNTRY PHONE
1 Shamima Iqbal Alabama USA 01829
2 Tanzila Khan London London 72081
3 Tasnim Zaman Dhaka Bangladesh 24647
4 Mahin Chowdhury Cumilla Bangladesh 83208
5 Arfana Alam California USA 37290
6 Anik Hasan Dhaka Bangladesh 44759
7 Rafsan Ahmed Rajshahi Bangladesh 08795
8 | P a g e
Document Page
Problem: List the first name, last name, and city of all customers
SELECT FirstName, LastName, City
FROM Customer
F. NAME L.NAME CITY
Shamima Iqbal Alabama
Tanzila Khan London
Tasnim Zaman Dhaka
Mahin Chowdhury Cumilla
Arfana Alam California
Anik Hasan Dhaka
Rafsan Ahmed Rajshahi
Where statement:
* To limit the number of rows use the WHERE clause.
* The WHERE clause filters for rows that meet certain criteria.
* WHERE is followed by a condition that returns either true or false.
* WHERE is used with SELECT, UPDATE, and DELETE
The SQL WHERE syntax:
*A WHERE clause with a SELECT statement:
SELECT column-names
FROM table-name
WHERE condition
9 | P a g e
Document Page
 A WHERE clause with an UPDATE statement
UPDATE table-name
SET column-name = value
WHERE condition
 A WHERE clause with a DELETE statement:
DELETE table-name
WHERE condition
SQL WHERE Clause Examples
Problem: List the customers in Sweden
SELECT Id, FirstName, LastName,
City, Country, Phone
FROM Customer
WHERE Country = 'USA'
ID F. NAME L.NAME CITY COUNTRY PHONE
1 Shamima Iqbal Alabama USA 01829
5 Arfana Alam California USA 37290
Problem: Update the city to Sydney for customer
10 | P a g e

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
UPDATE Customer
SET City = 'Alabama'
WHERE Name = 'Shamima'
Problem: Delete all products with unit price higher than $100
DELETE FROM Product
WHERE Unit Price > 100
Note: This deletion may be prevented by referential intergrity
One of the better approach may be to discontinue the product, that is, set is
discontinued to true.
SQL insert into statement:
*The INSERT INTO statement is used to add new data to a database.
* The INSERT INTO statement adds a new record to a table.
* INSERT INTO can contain values for some or all of its columns.
* INSERT INTO can be combined with a SELECT to insert records.
The SQL INSERT INTO syntax
The general syntax is:
INSERT INTO table-name
(column-names)
VALUES (values)
SQL INSERT INTO Examples
11 | P a g e
Document Page
Problem: Add a record for a new customer
*INSERT INTO Customer (FirstName, LastName, City, Country)
VALUES ('Shamima', 'Iqbal’, 'Alabama', 'USA')
Problem: Add a new customer named Anita Coats to the database
INSERT INTO Customer (FirstName, LastName)
VALUES ('Tanzila', 'Khan')
*The SQL INSERT combined with a SELECT
INSERT INTO table-name (column-names)
SELECT column-names
FROM table-name
WHERE condition
SQL update statement:
*The UPDATE statement updates data values in a database.
*UPDATE can update one or more records in a table.
*Use the WHERE clause to UPDATE only specific records.
The SQL UPDATE syntax
The general syntax is given below:
12 | P a g e
Document Page
UPDATE table-name
SET column-name = value
To limit the number of records to UPDATE append a WHERE clause:
UPDATE table-name
SET column-name = value, column-name = value
WHERE condition
*SQL UPDATE Examples
Problem: discontinue all products in the database
UPDATE Product
SET IsDiscontinued = 1
Problem: Discontinue products over $60
UPDATE Product
SET IsDiscontinued = 1
WHERE UnitPrice > 60
Problem: Discontinue product with Id = 1
UPDATE Product
SET IsDiscontinued = 1
WHERE UnitPrice > 60
Problem: Customer Mahin Chowdhury (Id = 4) has moved: update their city,
phone
13 | P a g e

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
UPDATE Supplier
SET City = 'Dhaka',
Phone = 83201,
WHERE Id = 4;
This is a common scenario in which a single record is updated.
SQL DELETE statement:
SQL DELETE Statement
DELETE permanently removes records from a table.
DELETE can delete one or more records in a table.
Use the WHERE clause to DELETE only specific records
*The SQL DELETE syntax
The general syntax is
DELETE table-name
To delete specific records append a WHERE clause:
DELETE table-name
WHERE condition
*SQL DELETE Examples
Problem: Delete all products
DELETE Product
*Problem: Delete products over $100
DELETE Product
14 | P a g e
Document Page
WHERE Unit Price > 100
Problem: Delete customer with Id = 1
DELETE Customer
WHERE Id = 1
This is a more common scenario in which a single record is deleted.
Results: 1 record deleted.
SQL order by:
SELECT returns records in no particular order.
To ensure a specific order use the ORDER BY clause.
ORDER BY allows sorting by one or more columns.
Records can be returned in ascending or descending order.
*The SQL ORDER BY syntax
The general syntax is:
SELECT column-names
FROM table-name
WHERE condition
ORDER BY column-names
SQL ORDER BY Examples
15 | P a g e
Document Page
Problem: List all Customers in alphabetical order
SELECT CompanyName, ContactName, City, Country
FROM Customer
ORDER BY CompanyName
The default sort order is ascending, that is, low-high or a-z.
*Problem: List all suppliers in reverse alphabetical order
SELECT CompanyName, ContactName, City,
Country
FROM Supplier
ORDER BY CompanyName DES
*Problem: List all customers ordered by country, then by city within each country
Ordering by one or more columns is possible.
SELECT FirstName, LastName, City, Country
FROM Customer
ORDER BY Country, City
*Problem: List all suppliers in the USA, Japan, and Germany, ordered by city, then
by company name in reverse order
SELECT Id, CompanyName, City, Country
FROM Supplier
WHERE Country IN ('USA', 'Bangladesh', 'London') ORDER BY Country ASC,
CompanyName DESC
16 | P a g e

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
This shows that you can order by more than one column.
ASC denotes ascending, but is optional as it is the default sort order.
*Problem: Show all orders, sorted by total amount, the largest first, within each
year
SELECT Id, OrderDate, CustomerId, TotalAmount
FROM [Order]
ORDER BY YEAR(OrderDate) ASC,
Total Amount DESC
Note: DESC means descending, but is optional as it is the default sort order.
[Order] must be bracketed because it also is a keyword in SQL.
ID Order Date Customer ID Total Amount
1 20-01-2020 101 10000
2 21-02-2020 102 20000
3 1-01-2020 103 15000
4 30-04-2020 104 10000
5 10-03-2020 105 20000
*SQL select top statement:
The SELECT TOP statement returns a specified number of records.
SELECT TOP is useful when working with very large datasets.
Non SQL Server databases use keywords like LIMIT, OFFSET, and
ROWNUM.
*The SQL SELECT TOP syntax
The general syntax is:
SELECT TOP n column-names
FROM table-name
17 | P a g e
Document Page
SQL SELECT TOP
*Problem: List top 10 most expensive products
SELECT TOP 10 Id, ProductName,
UnitPrice, Package
FROM Product
ID Product Name Unit Price Package
41 Potato Crackers 10tk 40pc
42 Mojo 15 24pc
43 Lays 25 40pc
44 Sprite 20 24pc
*SQL select Distinct statement:
SELECT DISTINCT returns only distinct (different) values.
SELECT DISTINCT eliminates duplicate records from the results.
DISTINCT can be used with aggregates: COUNT, AVG, MAX, etc.
DISTINCT operates on a single column. DISTINCT for multiple columns is
not supported.
*The SQL SELECT DISTINCT syntax
The general syntax is:
--SELECT DISTINCT column-name
FROM table-name
(Can be used with COUNT and other aggregates)
--SELECT COUNT (DISTINCT column name)
18 | P a g e
Document Page
FROM table-name
*SQL SELECT Examples
Problem: List all supplier countries in alphabetical order
SELECT DISTINCT Country
FROM Supplier
ORDER BY COUNTRY
*SQL useful functions:
1. SQL has many built-in functions for performing processing on string or
numeric data. Following is the list of all useful SQL built-in functions
2. SQL COUNT Function - The SQL COUNT aggregate function is used to
count the number of rows in a database table.
3. SQL MAX Function - The SQL MAX aggregate function allows us to select
the highest (maximum) value for a certain column.
4. SQL MIN Function - The SQL MIN aggregate function allows us to select
the lowest (minimum) value for a certain column.
5. SQL AVG Function - The SQL AVG aggregate function selects the average
value for certain table column.
6. SQL SUM Function - The SQL SUM aggregate function allows selecting
the total for a numeric column.
7. SQL SQRT Functions - This is used to generate a square root of a given
number.
8. o SQL RAND Function - This is used to generate a random number using
SQL command.
9. SQL CONCAT Function - This is used to concatenate any string inside any
SQL command.
10.SQL Numeric Functions - Complete list of SQL functions required to
manipulate numbers in SQL.
19 | P a g e

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
11.SQL String Functions - Complete list of SQL functions required to
manipulate strings in SQL.
SQL select MIN, MAX statement:
ELECT MIN returns the minimum value for a column.
SELECT MAX returns the maximum value for a column
*The SQL SELECT MIN and MAX syntax
The general MIN syntax is:
--SELECT MIN(column-name)
FROM table-name
The general MAX syntax is:
--SELECT MAX(column-name)
FROM table-name
Problem: Find the cheapest product
--SELECT MIN(UnitPrice)
FROM Product
SQL SELECT MAX and MIN Examples
Problem: Find the largest order placed in 2014
--SELECT MAX(TotalAmount)
FROM [Order]
WHERE YEAR(OrderDate) = 2014
20 | P a g e
Document Page
Problem: Find the last order date in 2013
SELECT MAX(OrderDate)
FROM [Order]
WHERE YEAR(OrderDate) = 2013
MIN and MAX can also be used with numeric and date types.
Results:
OrderDate
2013-12-01
SQL select COUNT, SUM, AVG statement:
SELECT COUNT returns a count of the number of data values.
SELECT SUM returns the sum of the data values.
SELECT AVG returns the average of the data values.
*The SQL SELECT COUNT, SUM, and AVG syntax
The general COUNT syntax is given below:
--SELECT COUNT(columnname)
FROM table-name
The general SUM syntax is:
SELECT SUM (column-name)
FROM table-name
21 | P a g e
Document Page
The general AVG syntax is:
SELECT AVG (column-name)
FROM table-name
SQL SELECT COUNT, SUM, and AVG Examples
Problem: Find the number of customers
--SELECT COUNT(Id)
FROM Customer
Results:
Count
91
Problem: Compute the total amount sold in 2013
--SELECT SUM(TotalAmount)
FROM [Order]
WHERE YEAR(OrderDate) = 2013
Results:
Sum
10000
Problem: Compute the average size of all orders
SELECT AVG (TotalAmount)
22 | P a g e

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
FROM [Order]
Results:
Average
2000
SQL select COUNT, SUM, AVG statement:
WHERE conditions can be combined with AND, OR, and NOT.
A WHERE clause with AND requires that two conditions are true.
A WHERE clause with OR requires that one of two conditions is true.
SELECT COUNT(Id) FROM Customer
*The WHERE with AND, OR, NOT syntax
A WHERE clause with AND:
--SELECT column-names
FROM table-name
WHERE condition1 AND
A WHERE clause with OR:
UPDATE table-name
SET column-name = value
WHERE condition1 OR
A WHERE clause with NOT
DELETE table-name
WHERE NOT condition
23 | P a g e
Document Page
SQL WHERE with AND, OR, and NOT Examples
Problem: Get customer named Rafsan Ahmed
SELECT Id, FirstName, LastName,
City, Country
FROM Customer
WHERE FirstName = ‘Rafsan’
ID F. NAME L.NAME CITY COUNTRY PHONE
7 Rafsan Ahmed Rajshahi Bangladesh 08795
Problem: List all customers from Spain or France
SELECT Id, FirstName, LastName,
City, Country
FROM Customer WHERE Country = 'Bangladesh' OR ‘USA’
ID F. NAME L.NAME CITY COUNTRY PHONE
1 Shamima Iqbal Alabama USA 01829
5 Arfana Alam California USA 37290
3 Tasnim Zaman Dhaka Bangladesh 24647
4 Mahin Chowdhury Cumilla Bangladesh 83208
5 Anik Hasan Dhaka Bangladesh 44759
7 Rafsan Ahmed Rajshahi Bangladesh 08795
24 | P a g e
Document Page
Problem: List all customers that are not from the USA
SELECT Id, FirstName, LastName, City, Country
FROM Customer
WHERE NOT Country = 'USA'
SQL Where between clause:
WHERE BETWEEN returns values that fall within a given range.
WHERE BETWEEN is a shorthand for >= AND <=.
BETWEEN operator is inclusive: begin and end values are included.
The SQL WHERE BETWEEN syntax
The general syntax is:
SELECT column-names
FROM table-name
WHERE column-name BETWEEN value1 AND value2
SQL Where IN clause:
WHERE IN returns values that matches values in a list or subquery.
WHERE IN is a shorthand for multiple OR conditions
The SQL WHERE IN syntax
the general syntax is
SELECT column-names
FROM table-name
25 | P a g e

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
WHERE column-name IN (values)
SQL WHERE IN Examples
Problem: List all customer from the USA, OR London
SELECT Id, CompanyName, City, Country
FROM Supplier
WHERE Country IN ('USA', ‘London')
SQL Where LIKE clause:
WHERE LIKE determines if a character string matches a pattern.
Use WHERE LIKE when only a fragment of a text value is known.
WHERE LIKE supports two wildcard match options: % and _.
The SQL WHERE LIKE syntax
The general syntax is
SELECT column-names
FROM table-name
WHERE column-name LIKE value
SQL NULL clause:
NULL is a special value that signifies 'no value'. Comparing a column to
NULL using the = operator is undefined. Instead, use WHERE IS NULL or
WHERE IS NOT NULL.
The SQL WHERE IS NULL syntax
--The general syntax is:
SELECT column-names
FROM table-name
WHERE column-name IS NULL
--The general not null syntax is:
SELECT column-names
26 | P a g e
Document Page
FROM table-name
WHERE column-name IS NOT NULL
SQL GROUP BY clause:
The GROUP BY clause groups records into summary rows.
GROUP BY returns one records for each group.
GROUP BY typically also involves aggregates: COUNT, MAX, SUM,
AVG, etc.
GROUP BY can group by one or more columns
The SQL GROUP BY syntax
--The general syntax is:
SELECT column-names
FROM table-name
WHERE condition
GROUP BY column-names
The general syntax with ORDER BY is:
SELECT column-names
FROM table-name
WHERE condition
GROUP BY column-names
ORDER BY column-names
SQL HAVING clause:
SQL HAVING Clause
HAVING filters records that work on summarized GROUP BY results.
HAVING applies to summarized group records, whereas WHERE
applies to individual records.
Only the groups that meet the HAVING criteria will be returned.
27 | P a g e
Document Page
HAVING requires that a GROUP BY clause is present.
The SQL HAVING syntax:
--The general syntax is:
SELECT column-names
FROM table-name
WHERE condition
GROUP BY column-names
HAVING condition
The general syntax with ORDER BY is:
SELECT column-names
FROM table-name
WHERE condition
GROUP BY column-names
HAVING condition
ORDER BY column-names
SQL Alias:
An Alias is a shorthand for a table or column name.
Aliases reduce the amount of typing required to enter a query.
Complex queries with aliases are generally easier to read.
Aliases are useful with JOINs and aggregates: SUM, COUNT, etc.
An Alias only exists for the duration of the query.
The SQL Alias syntax
--The general syntax is given below
SELECT column-name AS alias-name
28 | P a g e

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
FROM table-name alias-name
WHERE condition
SQL JOIN:
A SQL JOIN combines records from two tables.
A JOIN locates related column values in the two tables.
A query can contain zero, one, or multiple JOIN operations.
INNER JOIN is the same as JOIN; the keyword INNER is optional.
Different types of JOINs:
(INNER) JOIN: Select records that have matching values in both tables.
LEFT (OUTER) JOIN: Select records from the first (left-most) table with
matching right table records.
RIGHT (OUTER) JOIN: Select records from the second (right-most) table
with matching left table records.
FULL (OUTER) JOIN: Selects all records that match either left or right
table records. All INNER and OUTER keywords are optional. Details about
the differences between these JOINs are available in subsequent tutorial
pages.
SQL UNION Clause
Union combines the result sets of two queries.
Column data types in the two queries must match.
UNION combines by column position rather than column name.
The SQL UNION syntax
--The general syntax is:
SELECT column-names
FROM table-name
29 | P a g e
Document Page
UNION SELECT column-names
FROM table-name
SQL Subqueries:
o A subquery is a SQL query within a query.
o Subqueries are nested queries that provide data to the enclosing query.
o Subqueries can return individual values or a list of records
o Subqueries must be enclosed with parenthesis
The SQL subquery syntax
There is no general syntax; subqueries are regular queries placed inside
parenthesis.
Subqueries can be used in different ways and at different locations inside a query:
Here is an subquery with the IN operator
SELECT column-names
FROM table-name
UNION SELECT column-names
FROM table-name
SQL WHERE, ANY, ALL clause:
ANY and ALL keywords are used with a WHERE or HAVING clause.
ANY and ALL operate on subqueries that return multiple values.
ANY returns true if any of the subquery values meet the condition.
ALL returns true if all of the subquery values meet the condition.
SQL WHERE EXISTS Statement:
WHERE EXISTS tests for the existence of any records in a subquery.
EXISTS returns true if the subquery returns one or more records.
30 | P a g e
Document Page
EXISTS is commonly used with correlated subqueries.
The general syntax is:
SELECT column-names
FROM table-name
WHERE EXISTS
SQL Injection:
SQL Injection is a code injection technique.
It is the placement of malicious code in SQL strings.
SQL Injection is one of the most common web hacking techniques.
These attacks only work with apps that internally use SQL.
SQL Keywords:
SQL Server uses reserved words for database operations.
Reserved keywords are part of the SQL Server T-SQL grammar.
SQL Server has claimed current and future reserved words.
Keywords can be used as identifiers by placing them between.
SQL Operators:
SQL operators are reserved keywords used in the WHERE clause of a SQL
statement to perform arithmetic, logical and comparison operations. Operators act
as conjunctions in SQL statements to fulfill multiple conditions in a statement.
Since, there are different types of operators in SQL, let us understand the same in
the next section of this article on SQL operators.
Types of SQL Operators
Arithmetic Operators
These operators are used to perform operations such as addition, multiplication,
subtraction etc.
31 | P a g e

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
operator operation description
+ addition Add values on either side
of the operator
- subtraction Used to subtract the right
hand side value from the
left hand side value
* multiplication Multiples the values
present on each side of
the operator
/ division Divides the left hand side
value by the right hand
side value
% modulus Divides the left hand side
value by the right hand
side value; and returns
the remainder
Comparison Operators:
These operators are used to perform operations such as equal to, greater than, less
than etc.
operator operation description
= Equal to Used to check if the
values of both operands
are equal or not. If they
are equal, then it returns
TRUE.
> greater than Returns TRUE if the
value of left operand is
greater than the right
operand
< less than Checks whether the value
of left operand is less
than the right operand, if
yes returns TRUE
32 | P a g e
Document Page
>= greater than or equal to Used to check if the left
operand is greater than or
equal to the right
operand, and returns
TRUE, if the condition is
true.
<= less than or equal to Returns TRUE if the left
operand is less than or
equal to the right
operand.
<> or != not equal to Used to check if values
of operands are equal or
not. If they are not equal
then, it returns TRUE
!> no greater than Checks whether the left
operand is not greater
than the right operand, if
yes then returns TRUE
!< no less than Returns TRUE, if the left
operand is not less than
the right operand.
Conclusions:
W3SCHOOLS.com discusses the basic operations by providing a
lot of syntax, exercises, and practices. WE can enrich our fundamental basic skill
in the world’s one the best demanding programming platform databases by
learning SQL/MySQL tutorial from this biggest educational platform.
33 | P a g e
Document Page
34 | P a g e
1 out of 34
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]