Using the IN operator to query for elements in a set list of criteria

Product(s): WaterGEMS, WaterCAD, HAMMER, SewerGEMS, SewerCAD, StormCAD, CivilStorm 
Version(s): CONNECT Edition
Area: Modeling

Problem

How can I select elements in a query that meet a specific list of criteria, for example pipes that have three specific diameters or junctions in three different zones?

Solution

In the Query tool (View > Queries), you can use standard SQL syntax to select elements. If you need to select elements in a specific set of criteria, the OR operator can be used. For example:

Diameter = 6 OR Diameter = 8 OR Diameter = 10

Or...

Physical_Zone = 116 OR Physical_Zone = 118

A shortened way to do this is to use the IN operator where the set of criteria is in parenthesis, separated by commas. For example:

Diameter IN (6,8,10)

Or...

Physical_Zone IN (116,118)


Note that some fields such as the Zone need to use the unique ID instead of the label. So in the example above, the numbers 116 and 118 represent the ID of two specific zones. The ID can be seen next to the label in the properties or in the Flextable, when the Element Identifier setting is set to "ID:Label". This can be found under File > Options > Hydraulic Model.

Note: An IN button has been added to the Query Builder in version 10.03.03.72 of WaterGEMS, WaterCAD, and HAMMER.

See Also

Query not returning results for fields that use a pick-list

Using the LIKE and IN Operators with queries to filter on text fields such as label

Recommended
Related