Navigation:  Query Builder > Query Types >

SQL Query - Example

 

If you are familiar with SQL (Structured Query Language) syntax commands, you can retrieve, manage and manipulate your data through the SQL Statement section of the Query Builder when editing a general query or a union query.

As soon as you begin typing within the SQL Statement section of the Query Builder you will be prompted to confirm that you wish only use the SQL Statement to create/edit the query.

 

 

 

When you select yes, you will notice the Display Fields, Conditions, and Group Conditions sections will become disabled. Moving forward, you can only edit the query by directly editing the SQL Statement.

 

 

 

The most commonly used command in SQL is the Select command which is described below. This command will return query the data based on a set of optional conditions for specified fields in one or more specified tables.

 

Select Command

The Select Command retrieves data from tables in a database and is usually followed by a "where" clause. For example, if you want to create a query to show all chemistry results where the chemical name is benzene, you would enter the following into the SQL Statement section:

 

SELECT * FROM parameter_result WHERE chemical_name = `Benzene'

 

As soon as you have entered a few characters you will see that the Query Builder autocomplete tool becomes available to help you write your SQL Statement.

 

 

 

Based on the first few letters of each word you enter the program will try and help you by suggesting SQL Commands (for example SELECT) or the names of tables or fields in your database.

Once you have completed entering the statement (ensure it is exactly as written above including the single brackets around the word Benzene) you can execute the the statement by selecting button.

You will be moved to the Data Query tab to see the results of your query.

 

 

 

Since we used the * in the Select statement ALL fields in the parameter results table will be displayed - but only the records containing Benzene will be displayed.

Select commands do not alter the underlying data. A more complete reference guide to the SQL language that interacts with the HGA database can be found here.

 

 


Page url:https://www.waterloohydrogeologic.com/help/hga/index.html?queries_using_sql_commands.htm