Understanding Queries

Top  Previous  Next

The querying process involves testing specific fields in a database looking for certain values. For example, you might be interested in places where is there is drinking water in a cave. You also might be interested in find places where the pH of a stream is greater than six. This kind of testing is done with a query.

 

When the query finds a row that matches your criteria, it returns a copy of that row. This way, you can selectively display and use rows that match you criteria.

 

Query Statements. Queries are made of simple logical equations that test specific fields in a database. A query statement consists of the three pieces: A Field Name, an Operator and a Target. Here is an example:

 

Field Name

Operator

Target

WaterPH

>

6

 

The Field Name tells the database where to look. The Operator tells the database how to compare and the Target specifies what value we are comparing against. In this query we are testing to see if the Water pH exceeds six. You were to run this query, the CaveBase would return rows that have a pH value greater the six. If the row also contained the name of the nearest survey station, you will be able locate all the places in the cave that have a high pH.

 

Combining Statements. You can also combine two or more statement to create a more complex query. For example:

 

        (WaterPH > 6) AND (Calcite = True)

 

This statement would return every row where the pH was greater the six and that had calcite present. Using this type of query, cavers were able to discover that all the massive gypsum beds in Lechuguilla Cave were located in the upper parts of the cave. This lent support to the theory that the cave was formed by rising hydrogen sulfide from the oil fields to the south.