(a) Outline the steps involved in creating the Query By Example (QBE) in figure 1 assuming the table customer exist already.
Figure 1
(b) Write the steps to generate the SQL statement for the action in 4 (a).
(a) Creating the Query By Example (QBE) in Microsoft Access, given that the Customer table already exists.
- Open the database and click the Create tab.
- Select Query Design.
- In the Show Table box, add the table tblCustomer to the QBE (query design) interface, then close the box.
- From the field list, select the field Last Name into the design grid.
- Select the field First Name into the design grid.
- Select the field Town into the design grid.
- In the Criteria row under the Last Name field, type John.
- Tick all the check boxes in the Show row under the Last Name, First Name and Town fields so that the three fields are displayed in the result.
- Click Run to execute the query, then save it with a suitable name.
(b) Generating the SQL statement for the query in 4(a).
Use any one of the following:
- Right-click on the Query (QBE) interface and select SQL View; or
- From Design View, click View and select SQL View; or
- Click on the SQL button at the bottom right corner of the window.
Access then displays the equivalent SQL for the query, of the form:
SELECT [Last Name], [First Name], Town FROM tblCustomer WHERE [Last Name] = 'John';