SQL queries can be carried out using the data fields of related or linked objects as well as the object type selected on the SQL dialog.
To see the full list of fields which can be queried for a specific object type, simply scroll through the list in the Field box of the SQL dialog.
The options us_links.<field> and ds_links.<field> are available for all link and node objects. In addition, the options us_nodes.<field> and ds_nodes.<field> are available for all link objects.
There are many other such linked objects depending on what has been selected in the Object Type field.
Some examples of SQL queries using connected object data fields are given below.
us_node.has_demand
selects all pipes that have at least one upstream node with demand.
SELECT WHERE us_links.length > 50
selects all nodes that have at least one upstream link with a length greater than 50.
SET user_text_1 = 'US link length > 50m' WHERE us_links.length > 50
sets user_text_1 to "US link length > 50m" on all nodes that have at least one upstream link with a length greater than 50.