In InfoWater a user can select network components and related data by creating logical query statements through the DB Query feature. A DB query allows the user to extract a set of records using logical statements on a field (or fields) stored within a specific database. Often used database query statements include boolean fields and searching a string in a field.
How to construct a Boolean DB Query
A Boolean field is intended to store a value of 1 or 0, where 1 corresponds to the term “Yes” and 0 to the term “No”.
InfoWater has built in boolean fields for check valves for pipe attributes and ‘allow overflow’ for tank attributes, nevertheless custom
Boolean fields can be created in the InfoWater information tables for any of the InfoWater feature types:
When creating a DB query based on a Boolean field simply select the Boolean field. This query will search for facilities whose fields are true or Yes (1):
To find Boolean fields where the field is false or No (0), enter the operator “.NOT.” prior to Boolean Field:
How to search a partial string match in an InfoWater field using DB Query?
There are three functions that prove helpful when searching a partial string in a string field. The following sections will show how the DB Query functions SUBSTR(), and the contain operator ($) can be used to find the following:
- When a field contains the partial string,
- The partial string is at the beginning of the string field
- The partial string is found near the end of the string field
- The partial string is at a specific part within the string field.
In this example the pipe IDs in the model contain the partial string ‘XY’ at different parts of the ID field. These queries were applied to the Domain and the Edit Domain Attributes tool was used to view the IDs of the facilities added to the Domain.
- To start let’s use the ‘Contain’ Operator ($) to find all ID fields that contain ‘XY’ partial string:
- Second find IDs that start with ‘XY’:
- Next use the SUBSTR() to find a partial string at the end of a string field:
- Finally, SUBSTR()to find partial string within the string field: