5 Z3 XC M5 SB FJVG6 QM
5 Z3 XC M5 SB FJVG6 QM
5 Z3 XC M5 SB FJVG6 QM
Page 1 of 6
© 2015-2024 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to www.savemyexams.com for more awesome resources
SQL
Your notes
SQL
What is SQL?
SQL (Structured Query Language) is a programming language used to interact with a DBMS.
The use of SQL allows a user to:
Select data
Order data
Sum data
Count data
Page 2 of 6
© 2015-2024 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to www.savemyexams.com for more awesome resources
Examples
Select all the fields from the Customers table
Command:
Output:
Page 3 of 6
© 2015-2024 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to www.savemyexams.com for more awesome resources
Select the ID, name & age of customers who are older than 25
Command:
Output:
ID Name Age
1 John Doe 30
3 Peter Lee 40
Select the name and country of customers who are from a country that begins with 'U'
Command:
Output:
Name Country
Page 4 of 6
© 2015-2024 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to www.savemyexams.com for more awesome resources
SELECT *
FROM Customers
WHERE City = 'London' OR City = 'Paris';
Output:
Worked Example
Below is a table of animals called tbl_animals
Blue Whale No 1
Orangutan Yes 1
Dolphin Yes 1
Page 5 of 6
© 2015-2024 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to www.savemyexams.com for more awesome resources
Kangaroo Yes 1
Penguin Yes 1
Complete this SQL statement to display all of the animal breeds that are currently breeding and
there was only one young born this year [3]
SELECT .................................................
FROM .................................................
WHERE .................................................
Answer
SELECT Animal [1]
FROM tbl_animals [1]
WHERE Number of Young == 1 [1]
Page 6 of 6
© 2015-2024 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers