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. We will use the sakila database and display all the films stored in the sakila database, that were released after 2004.

To create a query visually:

  1. Create a server connection. For more information about how to create a server connection see How To: Connect to a Database.
  2. On the Start page click SQL Development and then click Query Builder. Now, you can drag-and-drop tables from the Database Explorer to the editor. Holding Ctrl, select the category, film, and film_category tables in Database Explorer, and drag-and-drop them over to the visual editor. Alternatively, right-click any of the selected tables, point to Send to, and then click Query Builder on the shortcut menu.

  3. Select the film_id and title checkboxes in the film table, and the name checkbox in the category table.

    Actually, our query is ready to be executed. However, we need to add a WHERE condition, to display the films that were released after 2004.

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

  5. Click enter value.

  6. Select release_year from the list.

  7. Click the equals sign and select greater than instead.

  8. Click enter a value and type 2004.

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

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