Creating SQL queries
InfoWorks WS Pro implements its own subset of SQL (Structured Query Language) for selecting and updating network objects using specified criteria.
To create a SQL query:
- Open a network. One of the network views must be the current active windowThe current Active Window in any Microsoft Windows application has a differently coloured title bar to all the other windows. In the default colour scheme, the active window title bar is blue, all other windows have a grey title bar..
- Choose Selection | SQL select, or click the (SQL select) button from the Operations toolbar. This opens the SQL dialog.
- In the SQL dialog, click the SQL tab to open the SQL page.
- On the SQL page, select the options to be used when running the query:
- Choose the type of object to be queried from the Object dropdown list. (The object type selected can be overridden by use of the FROM keyword. See SQL syntax for more details.)
- Choose GIS select options, if using a GIS background layer as part of the query process.
- Apply the query to currently selected objects only by checking the Apply Filter to Current Selection option. (The setting of this option can be overridden by use of the keywords ALL and SELECTED. See SQL syntax for more details.)
- Enter the SQL query in the text box at the bottom
of the dialog. The Field dropdown list contains
only valid field names for the object type selected, and the GIS
Field dropdown list contains only valid GIS field names for the
GIS layer selected. Choosing fields from either of these lists automatically
adds them to the query.
Tip: Starting a section of text with /* and finishing it with */ will turn that part into a comment, and it will consequently be ignored when the query is executed.
- Validate the syntax by clicking the Test button.
- To save the query for future use, see Saving SQL queries as stored queries.
- Carry out the query by clicking the Apply or Run button. (The dialog is closed after the query has been run if the Run button is used, but will remain open if the Apply button is used.)