---
title: "Database Query"
canonical: "https://help.innovyze.com/space/infowaterpro/18055591/Database%20Query"
format: markdown
---
A query of a database allows you to extract a record (or records) of a data using logical statements on a field (or fields) stored within a specific database. With InfoWater Pro, you are able to select network components and related data by creating logical query statements through the user-friendly DB Query feature.

## Using Queries in InfoWater Pro

DB Query is a time-saving tool that can be used for:

- Activating a portion of the network for simulation, typically as a facility set associated with a custom scenario (see [Facility Manager](https://help-innovyze.atlassian.net/wiki/spaces/infowaterpro/pages/18055541)).
- Creating a domain to highlight a subset of network components (see [Domain Manager](https://help-innovyze.atlassian.net/wiki/spaces/infowaterpro/pages/18055548).)
- Restricting the database records that are available for editing using the Database Editor.
- Customizing the map display by color-coding network components (see [Query Sets](https://help-innovyze.atlassian.net/wiki/spaces/infowaterpro/pages/18055595)).
- Creating Selection Sets.
- Output Relates (stored output result data) can also be associated with DB Queries which are important when creating Query Reports.
- Restricting model results to identify network components whose modeled performance (pressures, flows, etc.) meet or do not meet user-specified criteria (e.g., nodes where pressure drops below 20 psi) using the Output Report Manager.

You may develop your own query statements or use one of the pre-defined InfoWater Pro special queries to select portions of your distribution system model.


## Methodology

To build a query statement, do the following:

- Click on **DB Query** from the **InfoWater Browser** -> **Operation**** tab**.
- Right click and choose the **New** command, and specify an ID and description (ID is no more than 20 characters, no spaces and Description is no more than 60 characters, may contain spaces) and click **OK**.
- Choose the Element Type that you want to create a query for (choose from **Junctions**, **Pumps**, **Tanks**, **Reservoirs**, **Valves** and **Pipes**) then click **OK**.
- Click **Query Builder** to launch the Query Builder dialog box.
- Choose the appropriate data tab from among the three tabs at the top of the Query Builder dialog box.
- Click on the column for the data type you want to query on.
- Choose on the operator from the functions and operator section.
- Enter the value that you want as your second operand in the Value Box.
- Click **Add** to add the query in the Statement section of the Query Builder.
- Click **Validate** to validate your query.
- Click **OK** to save your query and exit from the Query Builder dialog box.


# DB Query Dialog Box

To create a Database Query, from the **Operation tab of the InfoWater Pro Browser**, select **DB Query** and right click and choose the **New** command.  

![image](media://c21b56c4-4ef5-48d7-9894-07f279943a11)


**Query ID & Description** - The query ID and description are displayed here.

  - Tip 1:  In InfoWater Pro an element ID is up to 32 characters long, no spaces and some symbols are restricted such as *#, %* etc. (dash "-" and underscore "_" characters are OK)
  - Tip 2:  Description is up to 60 characters with spaces and symbol characters.
  - Tip 3:  A good description always helps identify the DB Query.

**Element Type** - Select the InfoWater Pro data element for which a query statement is to be made on the elements database. Choose from among the following different elements.


> ⚠️ Make sure to choose the right element type to create the query.

  


**Disable Output Relates Lookup** - Check this box to prevent output relates from being associated with a database query. 

**Query Statement Tab** - Shows the current query statement associated with the highlighted database query. In case you want to create a new query, click on the **Query Builder** button to open the Query Builder dialog box.

**Output Relate Tab** - Show the output relate.

** Query Builder**  - Click on the **DB query** icon to launch the Query Builder dialog box.