Creating a Query in Query Builder

This topic explains how to create and edit an SQL query in dbForge Fusion using the Query Builder features.

We are going to create a sample query using visual designer. Let’s repeat the sample we have created in the How To: Create and Edit a Query topic. We will use the HR database and display all the employees stored in the HR database, that are working in Shipping department with department ID number 50.

To create a query visually:

  1. Create a server connection. For more information about how to create a server connection see Connecting to a Database.
  2. On the Fusion menu, click New Query. Alternatively, click Create New Query on the Devart-Main toolbar. Now, you can drag-and-drop tables from the Database Explorer to the editor. Holding CTRL, select the DEPARTMENTS and EMPLOYEES tables in the Database Explorer, and drag-and-drop them over to the visual editor.

    Drag Tables

  3. Select the DEPARTMENT_ID and DEPARTMENT_NAME checkboxes in the DEPARTMENTS table, and the EMPLOYEE_ID, FIRST_NAME, and LAST_NAME checkboxes in the EMPLOYEES table.

    Select Checkboxes

    Actually, our query is ready to be executed. However, we need to add a WHERE condition, to display all the employees working in the Shipping department.

  4. Go to the Where tab to insert the condition. Click the green plus icon.

    Add Condition

  5. Click enter a value.

    Enter Value

  6. Select DEPARTMENT_ID from the list and then press ENTER.

    Department ID

  7. Click enter a value, type 50, and then press ENTER.

    50

  8. Click Execute. The result set displays the information we have requested.

    resultsqb

As you can see the results are the same we have in the Creating and Editing a Query topic.

Visual Query Builder is a powerful tool that allows you to build complex queries quickly and with no code typing.