Tools - SQL Query Wizard

This wizard allows you to quickly create a simple SQL query to retrieve data from a single table.

The tool has a user-friendly interface that guides you by the hand through all the steps of creating an SQL query - from selecting the fields of the table from which you want to retrieve data, to specifying the conditions that must be met, to determining the order in which the records will be returned.

Each step is a separate page. You can navigate through the boards using the Next and Back buttons.

Launching

You can run the wizard with the command located in the pop-up menu for the table on the tree in the MySQL Inspector tab. The command icon is shown next to it.

The second place from which you can open the SQL Query Wizard is the Create Database Query page in the Database Export Wizard.

Table selection

The first page allows you to select the table and its fields that will be added to the query.

Table
Select from the drop-down list the table from which you want to retrieve data. By default, the table you clicked on to start the wizard is selected.

Fields
Select in the list the fields of the selected table to be added to the query.

Conditions

This page provides options for specifying the conditions that the returned records must meet. Select one of the options:

include all records

only include records that meet the condition:

If you choose the second option, the text box for entering conditions (the section after the WHERE word in the SQL query) will become active, as well as the elements that facilitate their creation (their use inserts the appropriate word in the place of the cursor in the query field):

Insert field name:
Select the name of a field in the previously selected table from the list. Click the plus button next to the list to insert the table field name into the condition being built.

Insert operator
Click the selected button to insert one of the operators into the created condition: AND, OR, NOT.

Comparisons
Click to expand the list containing various comparison operators, such as LIKE, REGEXP, etc.

Mathematical
Click to expand the list containing various mathematical functions, such as Abs(), Sin(), etc.

Strings
Click to expand the list containing various text handling functions, such as Concat(), RTrim(), etc.

Date and time
Click to expand the list containing various date and time handling functions, such as Month(), Now(), etc.

Specifying the sort order of records

The next page allows you to specify record sorting for up to three fields. For this purpose, there are three drop-down lists with the names of the fields taken from the database:

  • Sort by
  • Then sort by
  • Then sort by

Under each of the lists there are switches for sort order (ascending or descending).

Other query options
Here you will find a toggle that allows you to insert a DISTINCT statement into the query, which will cause duplicate records to be removed (each record will only occur once).

End

The last page is a summary. It contains a text box displaying the finished query. In addition, you can use the Add Query to Favorites button, so you can save the built query for later reuse (a button to use one of the "Favorite Queries" can be found on the MySQL Inspector tab on the button bar next to the list of table contents).

The last action to perform is to click Finish, which will execute the query and close the Wizard. The results of the Wizard will be displayed in the table contents list at the bottom of the MySQL Inspector tab.

Related topics

To top