In this exercise, use the SQL builder to create a SELECT statement for the VIDEOS database, add the necessary database tables to the statement, and then assign aliases to each of the tables.
You can add SELECT, INSERT, DELETE, UPDATE, WITH, and FULLSELECT statements by using a command on the pop-up menu of the SQL Scripts folder in the Data Definition view. You will now create a SELECT statement for the VIDEOS database.
To create a SELECT statement:
The SQL builder has three panes:
You will use all of these panes throughout this tutorial.
In addition to the Data Project Explorer view, you can use the following three views with the SQL builder:
The SELECT statement that you created is already open in the SQL builder, so you can continue to construct it. You are creating only a SELECT statement in this tutorial, but you can also use the SQL Source pane, the Tables pane, and the Design pane of the SQL builder to create INSERT, DELETE, UPDATE, FULLSELECT, and WITH SQL statements.
You will now add three tables to the SELECT statement for the customerRentals query. You are creating a query that lets the video store employees look up the video titles that a particular customer has rented and the day of the week that the videos are due. The query needs to include the CUSTOMERS, RENTALS, and VIDEOS tables.
To add tables to the statement:
Next, you will create an alias for each of the tables in the SELECT statement. An alias is an indirect method of referencing a table so that an SQL statement can be independent of the qualified name of that table. If the table name changes, only the alias definition must be changed.
The aliases for the CUSTOMERS, RENTALS, and VIDEOS tables will be C, R, and V, respectively.
To add table aliases: