Find an Answer
The child() function returns the nth child node. This query does not work without both arguments.
The child() function returns a tree, and takes 2 parameters, a path and an integer:
tree child(tree input, integer n)
| return value: | function(parameters): |
| tree | child(tree input, integer n) |
The child() function returns a tree.
The child() function give the nth child. Note that the n starts with 1 rather than 0.
You can run the following examples against your own data in the GoToAssist search field, or against fictitious data in the Query Sandbox:
Query: What is the fifth child node of each interface node?
SELECT child(interface, 5) FROM /network/device
Results: Depending on the database, this query returns results similar to this:
row
child(interface, 5)
mac_address 00:10:DB:3A:F7:70
inet
ip_address 192.168.1.2
netmask 255.255.255.0
row
child(interface, 5)
name 3
mac_address 00:10:83:09:DC:68
admin_status 1
oper_status 1
type 6
speed 100000000
out_errors 0
in_errors 0
mtu 1514
out_octets 233999484
in_octets 4045888492
descr 3
if_index 3
row
child(interface, 5) null
. . .
Query: What is the first child of each inet node?
SELECT name, child(inet, 1) FROM /network/device/interface
Results: Depending on the database, this query returns results similar to this:
row name vlan1 child(inet, 1) null row name ethernet2 child(inet, 1) 1.4.6.26 row name ethernet3 child(inet, 1) 1.2.3.66 . . .
Query: What is the third child of each properties node?
select child(properties, 3) from /directory/item
Results: Depending on the database, this query returns results similar to this:
row child(properties, 3) MSSQLSvc/jane-doe.altoworks.local,HOST/jane-doe.altoworks.local,HOST/VOLANS row child(properties, 3) 249,196,225,97,192,130,209,64,157,94,210,243,190,177,235,40 row child(properties, 3) HOST/earth.altoworks.local,HOST/EARTH
Note: Since the order of children is random, the Ontology may not indicate which child will turn up in the results:
To see other PQL functions, see Functions.
Related topics