SlideShare a Scribd company logo
1 of 27
MySQL
LIMIT
MySQL LIMIT Clause
The MySQL LIMIT clause is used to limit the number of rows
returned by a SELECT query. It allows you to specify the maximum
number of rows to retrieve from the result set. This can be useful
when you have a large dataset and only want to retrieve a subset of
the data. The LIMIT clause is typically used in conjunction with the
SELECT statement.
LIMIT Syntax
SELECT column_name(s)
FROM table_name
WHERE condition
LIMIT number;
The following SQL statement selects the first three records from the "Customers" table:
TRY: SELECT * FROM Customers
LIMIT 3;
What if we want to select records 4 - 6 (inclusive)?
MySQL provides a way to handle this: by using OFFSET.
The SQL query below says "return only 3 records, start on record 4 (OFFSET 3)":
TRY: SELECT * FROM Customers
LIMIT 3 OFFSET 3;
ADD a WHERE CLAUSE
The following SQL statement selects the first three records from the "Customers" table,
where the country is "Germany":
Try: SELECT * FROM Customers
WHERE Country='Germany’
LIMIT 3;
MySQL MIN() and MAX() Functions
In MySQL, the MIN() and MAX() functions are used to find the
minimum and maximum values, respectively, from a specified column
in a table. These functions are often used in conjunction with the
SELECT statement to perform calculations or retrieve specific data
from a dataset.
MIN() Syntax
The MIN() function returns the smallest value of the selected column.
SELECT MIN(column_name)
FROM table_name
WHERE condition;
The following SQL statement finds the price of the cheapest product:
TRY: SELECT MIN(Price) AS SmallestPrice
FROM Products;
MAX() Syntax
The MAX() function returns the largest value of the selected column.
SELECT MAX(column_name)
FROM table_name
WHERE condition;
The following SQL statement finds the price of the most expensive
product:
TRY: SELECT MAX(Price) AS LargestPrice
FROM Products;
MySQL COUNT(), AVG() and SUM() Functions
In MySQL, the COUNT(), AVG(), and SUM() functions are used to
perform calculations on data in a database table. These aggregate
functions allow you to count rows, calculate averages, and sum up
values in a specified column.
COUNT() Syntax
The COUNT() function returns the number of rows that matches a
specified criterion.
SELECT COUNT(column_name)
FROM table_name
WHERE condition;
The following SQL statement finds the number of products:
TRY: SELECT COUNT(ProductID)
FROM Products;
AVG() Syntax
The AVG() function returns the average value of a numeric column.
SELECT AVG(column_name)
FROM table_name
WHERE condition;
The following SQL statement finds the average price of all products:
TRY: SELECT AVG(Price)
FROM Products;
SUM() Syntax
The SUM() function returns the total sum of a numeric column.
SELECT SUM(column_name)
FROM table_name
WHERE condition;
The following SQL statement finds the sum of the "Quantity" fields in the
"OrderDetails" table:
TRY: SELECT SUM(Quantity)
FROM OrderDetails;
Exercises:
1. Use the MIN function to select the record with the smallest value of
the Price column.
SELECT________
FROM Products;
2. Use an SQL function to select the record with the highest value of
the Price column.
SELECT________
FROM Products;
3. Use the correct function to return the number of records that have the Price value set
to 18.
SELECT ________
FROM Products
WHERE Price = 18;
4. Use an SQL function to calculate the average price of all products.
SELECT ________
FROM Products;
5. Use an SQL function to calculate the sum of all the Price column values in
the Products table.
SELECT ________
FROM Products;
Exercises:
1. Use the MIN function to select the record with the smallest value of
the Price column.
SELECTMIN(Price)
FROM Products;
2. Use an SQL function to select the record with the highest value of
the Price column.
SELECTMIN(Price)
FROM Products;
3. Use the correct function to return the number of records that have the Price value set
to 18.
SELECT COUNT(*)
FROM Products
WHERE Price = 18;
4. Use an SQL function to calculate the average price of all products.
SELECT AVE(Price)
FROM Products;
5. Use an SQL function to calculate the sum of all the Price column values in
the Products table.
SELECT SUM(Price)
FROM Products;
MySQL LIKE Operator
In MySQL, the LIKE operator is used in a SELECT statement to search for a
specified pattern in a column. It is commonly used to perform pattern matching
within text or string data. The LIKE operator is useful for finding rows that match a
certain pattern or contain specific substrings.
There are two wildcards often used in conjunction with the LIKE operator:
• The percent sign (%) represents zero, one, or multiple characters
• The underscore sign (_) represents one, single character
LIKE Syntax
SELECT column1, column2, ...
FROM table_name
WHERE columnN LIKE pattern;
a. The following SQL statement selects all customers with a CustomerName starting with "a":
TRY: SELECT * FROM Customers
WHERE CustomerName LIKE 'a%’;
b. The following SQL statement selects all customers with a CustomerName ending with "a":
TRY: SELECT * FROM Customers
WHERE CustomerName LIKE ’%a’;
LIKE Syntax
SELECT column1, column2, ...
FROM table_name
WHERE columnN LIKE pattern;
c. The following SQL statement selects all customers with a CustomerName that have "or" in any
position:
TRY: SELECT * FROM Customers
WHERE CustomerName LIKE '%or%’;
d. The following SQL statement selects all customers with a CustomerName that have "r" in the
second position:
TRY: SELECT * FROM Customers
WHERE CustomerName LIKE '_r%';
LIKE Syntax
SELECT column1, column2, ...
FROM table_name
WHERE columnN LIKE pattern;
e. The following SQL statement selects all customers with a CustomerName that starts with "a"
and are at least 3 characters in length:
TRY: SELECT * FROM Customers
WHERE CustomerName LIKE 'a__%’;
f. The following SQL statement selects all customers with a ContactName that starts with "a" and
ends with "o":
TRY: SELECT * FROM Customers
WHERE ContactName LIKE 'a%o';
LIKE Syntax
SELECT column1, column2, ...
FROM table_name
WHERE columnN LIKE pattern;
g. The following SQL statement selects all customers with a CustomerName that does NOT start
with "a":
TRY: SELECT * FROM Customers
WHERE CustomerName NOT LIKE 'a%';
Exercises:
1. Select all records where the value of the City column starts with the letter
"a".
SELECT * FROM Customers
WHERE City LIKE ‘a%’;
2. Select all records where the value of the City column ends with the letter
"a".
SELECT * FROM Customers
WHERE City LIKE ‘%a’;
Exercises:
3. Select all records where the value of the City column contains the letter "a".
SELECT * FROM Customers
WHERE City LIKE ‘%a%’;
4. Select all records where the value of the City column starts with letter "a"
and ends with the letter "b".
SELECT * FROM Customers
WHERE City LIKE ‘a%b’;
5. Select all records where the value of the City column does NOT start with the
letter "a".
SELECT * FROM Customers
WHERE City NOT LIKE ‘a%’;

More Related Content

Similar to ADV Powepoint 3 Lec.pptx

Similar to ADV Powepoint 3 Lec.pptx (20)

SQL report
SQL reportSQL report
SQL report
 
MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index Tuning
 
Unit 3-Select Options and Aggregate Functions in SQL (1).pptx
Unit 3-Select Options and Aggregate Functions in SQL (1).pptxUnit 3-Select Options and Aggregate Functions in SQL (1).pptx
Unit 3-Select Options and Aggregate Functions in SQL (1).pptx
 
Oracle sql tuning
Oracle sql tuningOracle sql tuning
Oracle sql tuning
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
SQL Beginners anishurrehman.cloud.pdf
SQL Beginners anishurrehman.cloud.pdfSQL Beginners anishurrehman.cloud.pdf
SQL Beginners anishurrehman.cloud.pdf
 
Mysql1
Mysql1Mysql1
Mysql1
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 
Chinabankppt
ChinabankpptChinabankppt
Chinabankppt
 
MySQL-commands.pdf
MySQL-commands.pdfMySQL-commands.pdf
MySQL-commands.pdf
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
Query
QueryQuery
Query
 
ADV Powepoint 4 Lec.pptx
ADV Powepoint 4 Lec.pptxADV Powepoint 4 Lec.pptx
ADV Powepoint 4 Lec.pptx
 
Sql query [select, sub] 4
Sql query [select, sub] 4Sql query [select, sub] 4
Sql query [select, sub] 4
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
 

More from ArjayBalberan1

MYSQL DATABASE MYSQL DATABASEGroup-1.pptx
MYSQL DATABASE MYSQL DATABASEGroup-1.pptxMYSQL DATABASE MYSQL DATABASEGroup-1.pptx
MYSQL DATABASE MYSQL DATABASEGroup-1.pptxArjayBalberan1
 
Appdev appdev appdev app devAPPDEV 1.2.pptx
Appdev appdev appdev app devAPPDEV 1.2.pptxAppdev appdev appdev app devAPPDEV 1.2.pptx
Appdev appdev appdev app devAPPDEV 1.2.pptxArjayBalberan1
 
Rizals-Family-Childhood-Early-Education.pptx
Rizals-Family-Childhood-Early-Education.pptxRizals-Family-Childhood-Early-Education.pptx
Rizals-Family-Childhood-Early-Education.pptxArjayBalberan1
 
MYSQL DATABASE Operating System Part2 (1).pptx
MYSQL DATABASE Operating System Part2 (1).pptxMYSQL DATABASE Operating System Part2 (1).pptx
MYSQL DATABASE Operating System Part2 (1).pptxArjayBalberan1
 
MYSQL DATABASE APP DEV POWERPOINT 1.pptx
MYSQL DATABASE APP DEV POWERPOINT 1.pptxMYSQL DATABASE APP DEV POWERPOINT 1.pptx
MYSQL DATABASE APP DEV POWERPOINT 1.pptxArjayBalberan1
 
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptxMYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptxArjayBalberan1
 
NETWORK-TOPOLOGIES-VARIOUS-TOPOLOGIES.pptx
NETWORK-TOPOLOGIES-VARIOUS-TOPOLOGIES.pptxNETWORK-TOPOLOGIES-VARIOUS-TOPOLOGIES.pptx
NETWORK-TOPOLOGIES-VARIOUS-TOPOLOGIES.pptxArjayBalberan1
 
MYSQL DATABASE MYSQL DATABASEINSERTION-SORT.pptx
MYSQL DATABASE MYSQL DATABASEINSERTION-SORT.pptxMYSQL DATABASE MYSQL DATABASEINSERTION-SORT.pptx
MYSQL DATABASE MYSQL DATABASEINSERTION-SORT.pptxArjayBalberan1
 
MYSQL DATABASE MYSQL DATABASE merge-sort-grp4.pptx
MYSQL DATABASE MYSQL DATABASE merge-sort-grp4.pptxMYSQL DATABASE MYSQL DATABASE merge-sort-grp4.pptx
MYSQL DATABASE MYSQL DATABASE merge-sort-grp4.pptxArjayBalberan1
 
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptxMYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptxArjayBalberan1
 
MYSQL DATABASE MYSQL DATABASEquick-sort.pptx
MYSQL DATABASE MYSQL DATABASEquick-sort.pptxMYSQL DATABASE MYSQL DATABASEquick-sort.pptx
MYSQL DATABASE MYSQL DATABASEquick-sort.pptxArjayBalberan1
 
Selection-sort-in-algorithm and complexity.pptx
Selection-sort-in-algorithm and complexity.pptxSelection-sort-in-algorithm and complexity.pptx
Selection-sort-in-algorithm and complexity.pptxArjayBalberan1
 
Week 7 Github - SI- Architecture.pptx
Week 7 Github - SI-  Architecture.pptxWeek 7 Github - SI-  Architecture.pptx
Week 7 Github - SI- Architecture.pptxArjayBalberan1
 
Week Topic Code Access vs Event Based.pptx
Week Topic Code Access vs Event Based.pptxWeek Topic Code Access vs Event Based.pptx
Week Topic Code Access vs Event Based.pptxArjayBalberan1
 
APP DEV POWERPOINT 2.pptx
APP DEV POWERPOINT 2.pptxAPP DEV POWERPOINT 2.pptx
APP DEV POWERPOINT 2.pptxArjayBalberan1
 

More from ArjayBalberan1 (20)

MYSQL DATABASE MYSQL DATABASEGroup-1.pptx
MYSQL DATABASE MYSQL DATABASEGroup-1.pptxMYSQL DATABASE MYSQL DATABASEGroup-1.pptx
MYSQL DATABASE MYSQL DATABASEGroup-1.pptx
 
Appdev appdev appdev app devAPPDEV 1.2.pptx
Appdev appdev appdev app devAPPDEV 1.2.pptxAppdev appdev appdev app devAPPDEV 1.2.pptx
Appdev appdev appdev app devAPPDEV 1.2.pptx
 
Rizals-Family-Childhood-Early-Education.pptx
Rizals-Family-Childhood-Early-Education.pptxRizals-Family-Childhood-Early-Education.pptx
Rizals-Family-Childhood-Early-Education.pptx
 
MYSQL DATABASE Operating System Part2 (1).pptx
MYSQL DATABASE Operating System Part2 (1).pptxMYSQL DATABASE Operating System Part2 (1).pptx
MYSQL DATABASE Operating System Part2 (1).pptx
 
MYSQL DATABASE APP DEV POWERPOINT 1.pptx
MYSQL DATABASE APP DEV POWERPOINT 1.pptxMYSQL DATABASE APP DEV POWERPOINT 1.pptx
MYSQL DATABASE APP DEV POWERPOINT 1.pptx
 
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptxMYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
 
NETWORK-TOPOLOGIES-VARIOUS-TOPOLOGIES.pptx
NETWORK-TOPOLOGIES-VARIOUS-TOPOLOGIES.pptxNETWORK-TOPOLOGIES-VARIOUS-TOPOLOGIES.pptx
NETWORK-TOPOLOGIES-VARIOUS-TOPOLOGIES.pptx
 
MYSQL DATABASE MYSQL DATABASEINSERTION-SORT.pptx
MYSQL DATABASE MYSQL DATABASEINSERTION-SORT.pptxMYSQL DATABASE MYSQL DATABASEINSERTION-SORT.pptx
MYSQL DATABASE MYSQL DATABASEINSERTION-SORT.pptx
 
MYSQL DATABASE MYSQL DATABASE merge-sort-grp4.pptx
MYSQL DATABASE MYSQL DATABASE merge-sort-grp4.pptxMYSQL DATABASE MYSQL DATABASE merge-sort-grp4.pptx
MYSQL DATABASE MYSQL DATABASE merge-sort-grp4.pptx
 
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptxMYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
 
MYSQL DATABASE MYSQL DATABASEquick-sort.pptx
MYSQL DATABASE MYSQL DATABASEquick-sort.pptxMYSQL DATABASE MYSQL DATABASEquick-sort.pptx
MYSQL DATABASE MYSQL DATABASEquick-sort.pptx
 
Selection-sort-in-algorithm and complexity.pptx
Selection-sort-in-algorithm and complexity.pptxSelection-sort-in-algorithm and complexity.pptx
Selection-sort-in-algorithm and complexity.pptx
 
Week 7 Github - SI- Architecture.pptx
Week 7 Github - SI-  Architecture.pptxWeek 7 Github - SI-  Architecture.pptx
Week 7 Github - SI- Architecture.pptx
 
HTML-Lab.pptx
HTML-Lab.pptxHTML-Lab.pptx
HTML-Lab.pptx
 
tableslist.pptx
tableslist.pptxtableslist.pptx
tableslist.pptx
 
Week Topic Code Access vs Event Based.pptx
Week Topic Code Access vs Event Based.pptxWeek Topic Code Access vs Event Based.pptx
Week Topic Code Access vs Event Based.pptx
 
MODULE-01.pptx
MODULE-01.pptxMODULE-01.pptx
MODULE-01.pptx
 
APP DEV POWERPOINT 2.pptx
APP DEV POWERPOINT 2.pptxAPP DEV POWERPOINT 2.pptx
APP DEV POWERPOINT 2.pptx
 
APPDEV 1.pptx
APPDEV 1.pptxAPPDEV 1.pptx
APPDEV 1.pptx
 
ADV PPT 2 LAB.pptx
ADV PPT 2 LAB.pptxADV PPT 2 LAB.pptx
ADV PPT 2 LAB.pptx
 

Recently uploaded

New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 

Recently uploaded (20)

New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 

ADV Powepoint 3 Lec.pptx

  • 2. MySQL LIMIT Clause The MySQL LIMIT clause is used to limit the number of rows returned by a SELECT query. It allows you to specify the maximum number of rows to retrieve from the result set. This can be useful when you have a large dataset and only want to retrieve a subset of the data. The LIMIT clause is typically used in conjunction with the SELECT statement.
  • 3. LIMIT Syntax SELECT column_name(s) FROM table_name WHERE condition LIMIT number; The following SQL statement selects the first three records from the "Customers" table: TRY: SELECT * FROM Customers LIMIT 3; What if we want to select records 4 - 6 (inclusive)? MySQL provides a way to handle this: by using OFFSET. The SQL query below says "return only 3 records, start on record 4 (OFFSET 3)": TRY: SELECT * FROM Customers LIMIT 3 OFFSET 3;
  • 4. ADD a WHERE CLAUSE The following SQL statement selects the first three records from the "Customers" table, where the country is "Germany": Try: SELECT * FROM Customers WHERE Country='Germany’ LIMIT 3;
  • 5.
  • 6. MySQL MIN() and MAX() Functions In MySQL, the MIN() and MAX() functions are used to find the minimum and maximum values, respectively, from a specified column in a table. These functions are often used in conjunction with the SELECT statement to perform calculations or retrieve specific data from a dataset.
  • 7. MIN() Syntax The MIN() function returns the smallest value of the selected column. SELECT MIN(column_name) FROM table_name WHERE condition; The following SQL statement finds the price of the cheapest product: TRY: SELECT MIN(Price) AS SmallestPrice FROM Products;
  • 8. MAX() Syntax The MAX() function returns the largest value of the selected column. SELECT MAX(column_name) FROM table_name WHERE condition; The following SQL statement finds the price of the most expensive product: TRY: SELECT MAX(Price) AS LargestPrice FROM Products;
  • 9.
  • 10. MySQL COUNT(), AVG() and SUM() Functions In MySQL, the COUNT(), AVG(), and SUM() functions are used to perform calculations on data in a database table. These aggregate functions allow you to count rows, calculate averages, and sum up values in a specified column.
  • 11. COUNT() Syntax The COUNT() function returns the number of rows that matches a specified criterion. SELECT COUNT(column_name) FROM table_name WHERE condition; The following SQL statement finds the number of products: TRY: SELECT COUNT(ProductID) FROM Products;
  • 12. AVG() Syntax The AVG() function returns the average value of a numeric column. SELECT AVG(column_name) FROM table_name WHERE condition; The following SQL statement finds the average price of all products: TRY: SELECT AVG(Price) FROM Products;
  • 13. SUM() Syntax The SUM() function returns the total sum of a numeric column. SELECT SUM(column_name) FROM table_name WHERE condition; The following SQL statement finds the sum of the "Quantity" fields in the "OrderDetails" table: TRY: SELECT SUM(Quantity) FROM OrderDetails;
  • 14.
  • 15. Exercises: 1. Use the MIN function to select the record with the smallest value of the Price column. SELECT________ FROM Products; 2. Use an SQL function to select the record with the highest value of the Price column. SELECT________ FROM Products;
  • 16. 3. Use the correct function to return the number of records that have the Price value set to 18. SELECT ________ FROM Products WHERE Price = 18; 4. Use an SQL function to calculate the average price of all products. SELECT ________ FROM Products; 5. Use an SQL function to calculate the sum of all the Price column values in the Products table. SELECT ________ FROM Products;
  • 17. Exercises: 1. Use the MIN function to select the record with the smallest value of the Price column. SELECTMIN(Price) FROM Products; 2. Use an SQL function to select the record with the highest value of the Price column. SELECTMIN(Price) FROM Products;
  • 18. 3. Use the correct function to return the number of records that have the Price value set to 18. SELECT COUNT(*) FROM Products WHERE Price = 18; 4. Use an SQL function to calculate the average price of all products. SELECT AVE(Price) FROM Products; 5. Use an SQL function to calculate the sum of all the Price column values in the Products table. SELECT SUM(Price) FROM Products;
  • 19. MySQL LIKE Operator In MySQL, the LIKE operator is used in a SELECT statement to search for a specified pattern in a column. It is commonly used to perform pattern matching within text or string data. The LIKE operator is useful for finding rows that match a certain pattern or contain specific substrings. There are two wildcards often used in conjunction with the LIKE operator: • The percent sign (%) represents zero, one, or multiple characters • The underscore sign (_) represents one, single character
  • 20.
  • 21. LIKE Syntax SELECT column1, column2, ... FROM table_name WHERE columnN LIKE pattern; a. The following SQL statement selects all customers with a CustomerName starting with "a": TRY: SELECT * FROM Customers WHERE CustomerName LIKE 'a%’; b. The following SQL statement selects all customers with a CustomerName ending with "a": TRY: SELECT * FROM Customers WHERE CustomerName LIKE ’%a’;
  • 22. LIKE Syntax SELECT column1, column2, ... FROM table_name WHERE columnN LIKE pattern; c. The following SQL statement selects all customers with a CustomerName that have "or" in any position: TRY: SELECT * FROM Customers WHERE CustomerName LIKE '%or%’; d. The following SQL statement selects all customers with a CustomerName that have "r" in the second position: TRY: SELECT * FROM Customers WHERE CustomerName LIKE '_r%';
  • 23. LIKE Syntax SELECT column1, column2, ... FROM table_name WHERE columnN LIKE pattern; e. The following SQL statement selects all customers with a CustomerName that starts with "a" and are at least 3 characters in length: TRY: SELECT * FROM Customers WHERE CustomerName LIKE 'a__%’; f. The following SQL statement selects all customers with a ContactName that starts with "a" and ends with "o": TRY: SELECT * FROM Customers WHERE ContactName LIKE 'a%o';
  • 24. LIKE Syntax SELECT column1, column2, ... FROM table_name WHERE columnN LIKE pattern; g. The following SQL statement selects all customers with a CustomerName that does NOT start with "a": TRY: SELECT * FROM Customers WHERE CustomerName NOT LIKE 'a%';
  • 25.
  • 26. Exercises: 1. Select all records where the value of the City column starts with the letter "a". SELECT * FROM Customers WHERE City LIKE ‘a%’; 2. Select all records where the value of the City column ends with the letter "a". SELECT * FROM Customers WHERE City LIKE ‘%a’;
  • 27. Exercises: 3. Select all records where the value of the City column contains the letter "a". SELECT * FROM Customers WHERE City LIKE ‘%a%’; 4. Select all records where the value of the City column starts with letter "a" and ends with the letter "b". SELECT * FROM Customers WHERE City LIKE ‘a%b’; 5. Select all records where the value of the City column does NOT start with the letter "a". SELECT * FROM Customers WHERE City NOT LIKE ‘a%’;