So far you've learned how to set up a database and how to insert data into it, so now you can learn how to extract data from your database. Arguably, SQL's most powerful feature is its ability to extract data, and extracting data can be as simple or complex as you require. You can simply extract data in the same form in which it was entered into the database, or you could query the database and obtain answers to questions that are not obvious from the basic data. In your example database, you can use SQL to find out which meeting locations are most popular, or you could find out which meeting locations are most popular for which film category. It might turn out that Windy Village has a particularly large number of sci-fi fans. If the film club decides to show a film at that location, you would be aware that a sci-fi film is likely to be popular. The ability to ask the database questions and get answers via SQL queries makes SQL so popular and useful.
The key to getting data out is the
SELECT statement, which in its basic form is very simple and easy to use. However, as you go through this chapter and then the advanced chapters, you see lots of extra options that make the
SELECT statement very powerful. Before getting too complicated, however, you need to familiarize yourself with the
At its simplest, the
SELECT requires you to tell it which columns and from what table you want to obtain data. The basic syntax ...