<< Click to Display Table of Contents >> Navigation: Albion 6 GIS User Guide > Appendix > APPENDIX A: Scripting in Albion GIS > Sample SQL Queries |
The following samples demonstrate some SQL queries.
It is important to be cogniscant of the fact that the SQL queries that one types in are in fact appended to 'SELECT * FROM table WHERE', before being executed by the SQL engine. SQL is a general purpose language that can be used to modify databases, but here we use it only to perform queries that do not alter data.
Format
All of the samples assume that the script is operating on a database record with the following fields and values:
Record |
distribution_zone |
original_diameter |
diameter |
material |
code |
---|---|---|---|---|---|
1 |
981 |
0.150 |
0.150 |
Steel |
HC200 |
2 |
982 |
0.200 |
0.300 |
PVC |
|
3 |
983 |
0.200 |
0.150 |
PVC |
HC203 |
Examples
Average of original and current diameters is greater than 0.15
(diameter + original_diameter) / 2 > 0.15
Records which match the query: 2,3
Diameter is greater than Original Diameter
diameter > original_diameter
Records which match the query: 2
Code is not NULL
code NOTNULL
Records which match the query: 1,3
Material is PVC and Diameter is 0.15
material = 'PVC' AND diameter = 0.15
Records which match the query: 3
Material is PVC or Code starts with 'HC'
material = 'PVC' OR code LIKE 'HC%'
Records which match the query: 1,2,3
Code ends in '03'
code LIKE '%03'
Records which match the query: 3