Create, delete and update

CRUD methods

A database will generally have what are abbreviated CRUD methods. CRUD is short for create retrieve, update and delete. These methods use a special language for databases called structured query language or SQL for short. In the GCSE course you do not need to know the CREATE command.

Retrieve

Retrieving data from a database is performed by the SELECT query.

Notice first that in SQL certain words are capitalised. The SELECT line is used to specify which fields we want to get from the database. You can use * as a wildcard to return all the fields from a table.

The FROM line is where you specify the table or tables from which data is being retrieved.

The WHERE line can use Boolean conditions and, or and not as well as relational operators to make more complex conditions. There are also special SQL commands to help you search such as using * as wildcard so a search for players with forename B* would find both player 1 and 3.

The ORDER BY command is optionally used to change the order of the output. If you don't specify asc or desc it will presume asc for ascending.

In the example below there is a Boolean condition and we select from two tables. You might see it written as tblPlayer.Forename when describing fields but as long as the field only exists in one table you don't have to specify the table first like this.

Knowledge check


Questions:
Correct:

Question text


© All materials created by and copyright S.Goff