Drill-down Results

When you run a query from a single table that has relationship, WinSQL Professional allows you to drill down to related rows in the associated table.

Prerequisites for Drill-down

The Drill-down feature will only work when:

·You are using WinSQL Professional

·The FROM clause in the SELECT statement contains only one table

·You have fetched the database catalog prior to running your query

·Either foreign or local relationships are defined in the table

Consider the following scenario as an example, which contains a database with four tables. Their relationships are displayed in the figure below. Notice that the ORDERS table has two parents, EMPLOYEE and CUSTOMER, and it has one child, LINEITEM.

 

 

When you run the following query in WinSQL Professional, it displays the columns containing primary and foreign key in a different color with a + (plus sign) next to the value.

Note: The following illustration is in Classic View.

 

 

The first column in this example contains the primary key from the ORDERS table, which displays in red. The two subsequent columns contain data that map to the CUSTOMER and EMPLOYEE tables and is defined as a foreign key. Data for these columns displays in blue.

You can click the + to display related data from the associated table. For example if you click the E_SSN column where the value is 50, WinSQL Professional will run another query that will pull the employees whose E_SSN equal 50, depicted as follows:

 

Note:

The following illustration is in Classic View.