Structured Query Language (SQL)
N5 SQL Cheat Sheet
What is SQL?
Structured Query Language (SQL) is a language that is used to interrogate a database. All this means is that you use SQL to perform operations on the database.
If you have used programs such as Microsoft Access these can be known as a Relational Database Management System and they are simply a front end that generates SQL behind the scenes. In this book we will be using the SQL syntax from MySQL.
SQL Operations
At National 5 you are expected you to be able to write and explain SQL commands to perform the following operations.
Query (Search) the database
Insert new information into a database
Update the information in a database
Delete existing information
Searching and Sorting
Editing a database is when new details are added to the database or existing details are changed.
Searching a database simply involves finding a particular set of information from the database, for example everyone whose surname is Smith. It is possible that a search will return zero results.
Sorting a database is the act of organising the database into another order, for example in ascending alphabetical order by surname from A to Z or in descending order by age from oldest learner to the youngest learner.
Select Statements - Quick Tutorials
Sorting Tutorial
Covers basic sorting of a table.
Select Statements - 1 Table and 2 Tables
SELECT Statements - 1 Table
This video covers the user of SELECT statements to return data from a single table. For more info see below:
SELECT Statements - 2 Tables
This covers how to use a SELECT statement when using more than one table. For more info see below:
Insert Statements
SQL Insert Statements
This video will cover how to INSERT new rows into a table.
For more info see below:
Update and Delete Statements
SQL Update Statements
This video will cover how to use an UPDATE statement to change existing rows within a table.
For more info see below:
SQL Delete Statements
This video will demonstrate how to use a DELETE query to remove rows from a table.
For more info see below: