title | titleSuffix | description | author | ms.author | ms.date | ms.topic | ms.service |
---|---|---|---|---|---|---|---|
Azure Digital Twins query language reference - FROM clause |
Azure Digital Twins |
Reference documentation for the Azure Digital Twins query language FROM clause |
baanders |
baanders |
02/25/2022 |
article |
azure-digital-twins |
This document contains reference information on the FROM clause for the Azure Digital Twins query language.
The FROM clause is the second part of a query. It specifies the collection and any joins that the query will act on.
This clause is required for all queries.
Use FROM DIGITALTWINS
(not case sensitive) to refer to the entire collection of digital twins in an instance.
You can optionally add a name to the collection of digital twins by adding the name to the end of the statement.
Basic:
:::code language="sql" source="~/digital-twins-docs-samples/queries/reference.sql" id="FromDigitalTwinsSyntax":::
To name the collection:
:::code language="sql" source="~/digital-twins-docs-samples/queries/reference.sql" id="FromDigitalTwinsNamedSyntax":::
Here's a basic query. The following query returns all digital twins in the instance.
:::code language="sql" source="~/digital-twins-docs-samples/queries/reference.sql" id="FromDigitalTwinsExample":::
Here's a query with a named collection. The following query assigns a name T
to the collection, and still returns all digital twins in the instance.
:::code language="sql" source="~/digital-twins-docs-samples/queries/reference.sql" id="FromDigitalTwinsNamedExample":::
Use FROM RELATIONSHIPS
(not case sensitive) to refer to the entire collection of relationships in an instance.
You can optionally add a name to the collection of relationships by adding the name to the end of the statement.
Note
This feature cannot be combined with JOIN
.
Basic:
:::code language="sql" source="~/digital-twins-docs-samples/queries/reference.sql" id="FromRelationshipsSyntax":::
To name the collection:
:::code language="sql" source="~/digital-twins-docs-samples/queries/reference.sql" id="FromRelationshipsNamedSyntax":::
Here's a query that returns all relationships in the instance.
:::code language="sql" source="~/digital-twins-docs-samples/queries/reference.sql" id="FromRelationshipsExample":::
Here's a query that returns all relationships coming from twins A
, B
, C
, or D
.
:::code language="sql" source="~/digital-twins-docs-samples/queries/reference.sql" id="FromRelationshipsFilteredExample":::
The FROM
clause can be combined with the JOIN
clause to express cross-entity traversals in the Azure Digital Twins graph.
For more information on the JOIN
clause and crafting graph traversal queries, see Azure Digital Twins query language reference: JOIN clause.
The following limits apply to queries using FROM
.
For more information, see the following sections.
No subqueries are supported within the FROM
statement.
The following query shows an example of what can't be done as per this limitation.
:::code language="sql" source="~/digital-twins-docs-samples/queries/reference.sql" id="FromNegativeExample":::
The FROM RELATIONSHIPS
feature cannot be combined with JOIN
. You'll have to select which of these options works best for the information you'd like to select.