Save
Databases Final
ORDER BY LIMIT
Save
Share
Learn
Content
Leaderboard
Learn
Created by
tiana okane
Visit profile
Cards (18)
Databases
A collection of data organized and structured to provide efficient retrieval, manipulation, and management of information
Structure
Query Language (SQL)
A programming language used to manage and manipulate
relational
databases
ORDER
BY
Ordering results from the database, sorting using
Ascending
or
Descending
ORDER
BY
SELECT columns
FROM
table
WHERE condition ORDER BY column direction
ORDER
BY -
ascending
SELECT *
FROM Pet ORDER
BY Age
ASC
ORDER
BY -
ascending
SELECT
* FROM Pet ORDER BY
NAME
ASC
ORDER BY - Descending
SELECT * FROM Pet ORDER BY Age DESC
Multiple ORDER Fields
1. ORDER BY
firstName
,
lastName
2. ORDER BY
Age
ASC,
BankBalance
DESC
ORDER
BY -
ascending
SELECT * FROM Pet ORDER
BY Type
,
Name
ASC
LIMIT
Restricting
the number of
records
in the returned set
LIMIT
- NO Offset
SELECT * FROM Pet LIMIT
0, 3
SELECT * FROM Pet LIMIT
3
LIMIT
- with Offset
SELECT * FROM Pet LIMIT
1
,
3
Pets
in Threes
LIMIT
- NO Offset
SELECT * FROM Pet LIMIT
0, 3
LIMIT - Offset 3 Rows
SELECT * FROM Pet LIMIT 3, 3
LIMIT
- Offset 6 Rows
SELECT * FROM Pet LIMIT
6, 3
LIMIT
- Offset
9
Rows
SELECT * FROM Pet LIMIT 9,
3
LIMIT
- Typical query
SELECT Name, Age FROM Pet WHERE Type = 'Dog' ORDER BY Age DESC LIMIT 0,
1