Retrieving and filtering data
As you will have noticed, databases usually consist of many tables where all the data is stored. The AdventureWorks
database contains 71 tables, including tables for Customers
, Products
, Orders
, and so on. The table names clearly describe the data that is stored in the table. If you need to create a list of new products, or a list of customers who ordered the most products, you would retrieve this information by creating a query. A query is an enquiry into the database made by using the SELECT
statement. The SELECT
statement is the first and most fundamental SQL statement that we are going to introduce in this chapter.
The SELECT
statement consists of a set of clauses that specifies which data will be included into a query result set. All the clauses of SQL statements are the keywords and, because of that, are written in capital letters. A syntactically correct SELECT
statement requires a mandatory FROM
clause which specifies the source of the data you want to...