STRUCTURED QUERY LANGUAGE (SQL)
Brief Description.
Structured Query Language is a data retrieval language used by database engines like MS Access.
It is fairly easy to understand the basic principles and it can be a
very powerful retrieval system when properly understood by the advanced user.
Some variations to the SQL language exist, Winlog32 uses Microsoft Access SQL.
Winlog32 uses SQL extensively for data retrieval for the Log and other databases.
The SQL queries generated in the Search window can be modified to provide greater filtering of results.
In most cases only some rudimentary knowledge of SQL is required.
It is beyond the scope of this help file to teach you SQL, but some basics are included to get you started.
There is plenty of information, instruction and examples of SQL to be found on the internet.
This section is mainly concerned with the Search Log function, but applies to anything related to SQL.
A very basic SQL instruction would look like:-
"SELECT * FROM DATA"
Select all (fields and records) from Data (DATA = database Table Name).
This instruction would retrieve and display ALL Records and Fields from the database table (Log).
"SELECT Field1, Field2 from DATA"
This instruction would retrieve ALL records but only Field1 and Field2.
The returned data can be filtered in many ways - here are a few examples:-
"SELECT * FROM DATA WHERE Field1 like G0*"
Select all fields but using WHERE retrieves (filters) only records where field1
match the criteria of G0*. e.g. all G0 callsigns would be retrieved.
N.B. Strings must be enclosed in .
Fields containing strings would normally be queried that way, however in the case of
fields containing numeric data, the following instruction would be used.
"SELECT * FROM DATA WHERE Field1 >144"
This would be used to retrieve numeric data only above value 144, N.B. Do NOT include
around a value, the numeric operators < = can be used.
"SELECT * FROM DATA WHERE Field1 BETWEEN 144 AND 145"
Retrieves values between two numbers, useful for defining frequency limits.
In the case of Dates more care is needed.
"SELECT * FROM DATA WHERE DateField BETWEEN #01/01/1999# AND #31/12/1999# ORDER BY
DATEField ASC"
N.B. # enclosing the dates (BETWEEN #DATE1# AND #DATE2# is optional if a range of dates
is required otherwise use > or = as in following example.
IMPORTANT. If your system date is set to MM/DD/YY then allow for this in your query.
Order by Field ASC - added at the end of the statement, Sorts the data by date
ASCending (or DESCending).
Multiple criteria can be added together using the AND (OR) keyword retrieved thus:
"SELECT * FROM DATA WHERE DateField > #01/01/1999# AND Field2 Like
G0* AND Field3 >= 14"
Conversely use the OR operator instead of the AND.
the NOT operator can be used thus: AND NOT LIKE etc.
In this instance, ALL fields where records match those criteria.
Avoid using = when matching strings with pattern matching, in which case use the LIKE operator.
The Search window contains a dropdown list of Field names for the various databases.
These must of course be substituted for field1, field2 etc. and the correct Table
Name (Log) must be substituted for DATA in the above examples.
To discover the correct Table Name for the database, generate a basic SQL statement,
the Table Name directly follows FROM in the statement.
The above examples are only a starting point in the language, extremely complex
statements can be used to retrieve virtually anything in any order from a database.
Some basic SQL KEYWORDS:
SELECT |
FROM |
WHERE |
LIKE |
BETWEEN |
AND |
OR |
NOT |
IN |
SOME |
* (ALL Fields) |
ORDER BY |
HAVING |
ASC |
DESC |
Pattern matching conventions apply to strings:
! # ? [A,J,M] [A-J] [1-5] [1,5,9] [!A, !B, !Z]
example:
G[M,W][3-6]*/P gets all GM3,4,5,6 & GW3,4,5,6 portables.
See also Pattern Matching Techniques
|