In chapter 2, we looked at a spreadsheet of fictional books to better understand some core concepts about tables in a relational database management system (RDBMS). With that spreadsheet in mind, we’re going to work with a table that looks a lot like that spreadsheet and see some of the ways we can retrieve data using the SELECT command.
First, though, let’s take a deeper look at your first query. Although it was simple, it had all the minimum components for a query. Let’s briefly examine those components as well as some potential problems regarding formatting and the use of certain words.
3.1 Rules for the SELECT statement
Chapters 1 and 2 discussed the conversational way to think about writing a query, so let’s take a moment to consider the technical aspects and requirements as well. Recall your first query, which looked like this:
SELECT Outcome FROM MyFirstQuery;
This statement has four components, each represented by a single word. Technically, the semicolon is a component as well, serving as the statement terminator, but we’ve already discussed the fact that it may not be required, so we won’t count it.
3.1.1 SELECT requirements
The words “Outcome” and “MyFirstQuery” reflect the data we want to select. These words are crucial because they provide the minimum information the database needs to retrieve data from a table. These requirements are
- What data is to be selected
- Where the data is to be selected