Queries are a method of requesting information from a database. A specialised programming language called SQLStructured query language - a programming language used to control databases. is often used to create queryA search or question performed inside a database. that retrieve information from a database.
SQL allows a user to SELECT fields FROM a table WHERE certain criteria are met.
For example, from the table below, SELECT 'Firstname','Lastname' FROM 'Customer ID' WHERE 'Town = Belfast':
Customer ID
Firstname
Lastname
Gender
Address
Town
C0
Alice
Anderson
F
13 Monk Way
Lisburn
C1
Bob
Buchannon
M
14b Iris Street
Belfast
C2
Conor
Crawley
M
17 Eblana Street
Armagh
C3
Davina
Devlin
F
53 Fitzwilliam St
Newry
C4
Edward
Ellison
M
42 Park View
Enniskillen
Customer ID
C0
Firstname
Alice
Lastname
Anderson
Gender
F
Address
13 Monk Way
Town
Lisburn
Customer ID
C1
Firstname
Bob
Lastname
Buchannon
Gender
M
Address
14b Iris Street
Town
Belfast
Customer ID
C2
Firstname
Conor
Lastname
Crawley
Gender
M
Address
17 Eblana Street
Town
Armagh
Customer ID
C3
Firstname
Davina
Lastname
Devlin
Gender
F
Address
53 Fitzwilliam St
Town
Newry
Customer ID
C4
Firstname
Edward
Lastname
Ellison
Gender
M
Address
42 Park View
Town
Enniskillen
This would return: Bob Buchannon.
The criteria for a SELECT query can contain:
Boolean operatorAND, OR and NOT. Used to build complex queries in a database. (AND, OR, NOT)