Structured query language (SQL)

<< Previous: File handling Next: Arrays >>

Databases and records

Databases are a form of storing data in tables that are made up of fields under which data is stored. A record is a single line in a database table i.e. The values for all fields in an entry. In the image below the entries for the surname field are shown in green and a record in red.



SQL select

SQL (Structured query language) is the language for searching a database for information. The search command has the format:



SELECT can either be followed by * which means all fields, or you can specify just the fields you want to see
FROM is where you specify the table/s the data is stored in
WHERE lets you specify criteria the data should match to be selected



LIKE and wildcards

The command LIKE can be added to a WHERE criteria along with a wildcard symbol to search for part of a criteria. The most commonly used wildcard symbols are * and %. The command below would find all email addresses ending gmail.com.



Boolean operators

The Boolean operators AND, OR and NOT can be used to make more complex searches.



Knowledge check


Questions:
Correct:

Question text


<< Previous: File handling Next: Arrays >>

© All materials created by and copyright S.Goff