Creating Queries
With all the preliminaries taken care of, you can roll up your sleeves and start writing SQL. The SQL statement you will use most is the SELECT statement. As its name implies, you use SELECT to select data from a table.Most SELECT statements require at least the following two parameters:
- What data you want to select, known as the select list. If you specify more than one item, you must separate each with a comma.
- The table (or tables) from which to select the data, specified with the FROM keyword.
The first SQL SELECT you will create is a query for a list of movies in the Films table. Type the code in Listing 6.1 as seen in Figure 6.12, then execute the statement by clicking the Execute button.
Listing 6.1. Simple SELECT Statement
SELECT
MovieTitle
FROM Films
Figure 6.12. SQL statements are entered in the SQL Query Tool's SQL Query field.
[View full size image]

Figure 6.13. The SQL Query Tool displays query results in the bottom half of the screen.
[View full size image]

TIP
You can enter SQL statements on one long line or break them up over multiple lines. All white-space characters (spaces, tabs, newline characters) are ignored when the command is processed. Breaking a statement into multiple lines and indent parameters makes it easier to read and debug.Here's another example. Type the code in Listing 6.2, then click the Execute button to display two columns as seen in Figure 6.14.
Listing 6.2. Multi-column SELECT Statement
SELECT
MovieTitle, PitchText
FROM Films
Figure 6.14. The SQL Query Tool displays the results of all specified columns.
[View full size image]

NOTE
SQL statements aren't case sensitive, so you can specify the SELECT statement as SELECT, select, Select, or however you want. Common practice, however, is to enter all SQL keywords in uppercase and parameters in lowercase or mixed case. This way, you can read the SQL code and spot typos more easily.Now modify the SELECT statement so it looks like the code in Listing 6.3, then execute it.
Listing 6.3. SELECT All Columns
This time, instead of specifying explicit columns to select, you use an asterisk (*). The asterisk is a special select list option that represents all columns. The data pane now shows all the columns in the table in the order in which they are returned by the database table itself.
SELECT
*
FROM Films
