Creating a Query in Query Builder

This topic explains how to create and edit an SQL query in dbForge Studio 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 Creating and Editing 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 Start page, click SQL Development and then click Query Builder. Now, you can drag-and-drop tables from Database Explorer to the editor. Holding CTRL, select the DEPARTMENTS and EMPLOYEES tables in Database Explorer, and drag-and-drop them over to the visual editor.

  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.

    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.

  5. Click enter a value.

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

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

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

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.