2. An SQL query
Consider a single database table below
Table name: Employees
ID | Title | First name | Surname | Address | City | Postcode | Telephone |
1 | Mr | Tom | Smith | 42 Mill Street | London | WE13GW | 010344044 |
2 | Mrs | Sandra | Jones | 10 Low Lane | Hull | HU237HJ | 022344033 |
3 | Mr | John | Jones | 10 Low Lane | Hull | HU237HJ | 022344033 |
If we wanted to extract all the records from this table, an SQL query shown below will do so
SELECT * FROM Employees
Let us break down this statement :-
The first term 'SELECT' means extract some records from the database without modifying them in any way.
The star * means 'all records'.
The FROM keyword is used to identify the table(s) to be accessed
'Employees' is the name of the table to be accessed.
So in English, this SQL statement is saying:
"Get me all records from the table called Employees"
This is fine and useful. But it is far more common to limit the records in some way so that only some of them are returned.
The next page discusses this.
Challenge see if you can find out one extra fact on this topic that we haven't already told you
Click on this link: Using a query in SQL