Visual Query Builder

Previous  Index  Next  How To Use

You can reach the Visual Query Builder by using its button in any code editor:

Visual Query Builder button

 

Using the button will open a dialog like the one below, if you have selected a SQL statement or there's only one statement available (like in, for example, the View Editor, it will display this statement visually.

 

 

The Visual Query Builder dialog

 

Selecting Tables and Columns

You can drag tables from the Availables Data Sources area to the Working Area. Check the columns or * that you want to see in the result and drag one column name from a table to another table and column to create a join. If foreign key constraints exist in the database, JOINs will be created automatically.

 

You can execute the current SQL statement and verify your results by using the green Run button on the toolbar. The dialog will switch to the Results section with the result of your SELECT statement. Click the button again and you'll go back to the query builder.

 

Using the Accept button will paste the current SQL in the code editor you used before starting the Visual Query Builder.

 

Note:

You can only build a SELECT statement with the Visual Query Builder.

 

Joins

If you have created a join by linking columns together via drag/drop operations, you can right click on the join to delete it or display the Link Options dialog. Double clicking a link will also display this dialog

 

Link Options dialog

 

Grouping/Functions/Sorting

At the bottom part of the Visual Query Builder dialog, the Columns section lists any sorting, grouping or other SQL functions like AVG on a per column basis.

Columns, Grouping, Functions and Sorting

 

You can select SQL functions and sorting via drop down boxes, selecting the empty entry removes the function or sorting order.

 

Subqueries

You can create "sub queries" in the SELECT clause, by right-clicking the Expression cell and selecting Insert Subquery. This will open up a new working area where you can edit your subquery.

 

Unions

The editor also allows you to create UNION-queries. If you right click the Q and select New Union SubQuery. You can switch between the first and additional parts of the query by clicking the different Qs.

 

Create a new Union Query

 

Derived Tables

For those database engines that support it, you can right click the working area and select Add subquery to start a "derived table" that's used in the FROM clause. This will create a button at the top of the dialog that allows you to switch between the main query and the derived table query.

 

Subqueries or derived tables

 

Other Query Options

Depending on the database engine you're using, a query can have more options. These can be accessed via a double click in the working area or a right click and selecting the option from the popup menu.

 

Microsoft SQL Server Query Options