Introduction to SQL Query Structure

SQL instructions are written in the form of statements, consisting of a specific statement and additional parameters and operands that apply to that statement. SQL statements and their modifiers are based upon official SQL standards and certain extensions relating to the specific database.

The most common operation in SQL is the query, which is performed with the declarative SELECT statement. SELECT allows you to retrieve data from one or more tables, or expressions.

A query contains the SELECT keyword, followed by a list of columns that are to appear in the resultant output. (Each column comprises the result of an expression, which can optionally reference one or more database fields.) An asterisk (*) can also be used to specify that the query should return all columns of the queried tables. SELECT is perhaps the most complex statement in SQL, with optional keywords and clauses that include:

In order to retrieve data from the ClearSCADA database and display that data, an SQL SELECT query should take the following basic format:


<field>, <field>, <field>


<database table>


<field> = 'Value'



For more information about each SQL clause, see the following sections:

Be aware that you may also want to consider including other SQL clauses, such as the GROUP BY clause, and the HAVING clause in your SQL query.

ATTENTION: SQL queries should be written by engineers who have the appropriate experience and knowledge of the SQL language. Running a badly designed SQL query can have an adverse affect on the system. All queries should include suitable restrictions to limit the number of records that are retrieved from the database. An SQL query that queries vast amounts of data will affect the performance of the server while that query executes.


ClearSCADA 2017 R2