• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

11. Advanced Database Techniques > 11.2. Drilldown Queries

Drilldown Queries

A drilldown query (sometimes referred to as master-detail) is one that starts by retrieving and displaying a relatively broad or general result set. Then, hyperlinks from one or more columns in the result set are used to call another template that performs a query based on URL parameters passed by the hyperlinks. This process is designed to narrow the number of records returned until a desired level of granularity is achieved, hence the name drilldown query.

For drilldown queries, you usually need two templates, but it is possible to use as many as you want to achieve the level of granularity you need. In a two-template drilldown application, the first template queries a data source and displays a summary (usually just a few fields) of every record in the data source meeting the user’s criteria. Hyperlinks from some of the fields in these results pass the primary key values of records to the second template. The second template then performs a query using the primary key value passed in via URL in the WHERE clause of the SELECT statement. The results (usually the full record) are then output to the browser. Example 11-6 demonstrates how a two-template drilldown query works by querying the EmployeeDirectory table and generating an HTML table containing the Name, Title, and Department of each employee.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint