แก้ไข

แชร์ผ่าน


Azure Digital Twins query language reference: WHERE clause

This document contains reference information on the WHERE clause for the Azure Digital Twins query language.

The WHERE clause is the last part of a query. It's used to filter the items that are returned based on specific conditions.

This clause is optional while querying.

Core syntax: WHERE

The WHERE clause is used along with a Boolean condition to filter query results.

A condition can be a function that evaluates to a Boolean result. You can also create your own Boolean statement using the properties of twins and relationships (accessed with .) with a comparison or contains-type operator.

Syntax

With properties and operators:

--SELECT ...
--FROM ...
WHERE <twin-or-relationship-collection>.<property> <operator> <value-to-compare>

With a function:

--SELECT ...
--FROM ...
WHERE <function-with-Boolean-result>

Arguments

A condition evaluating to a Boolean value.

Examples

Here's an example using properties and operators. The following query specifies in the WHERE clause to only return the twin with a $dtId value of Room1.

SELECT *
FROM DIGITALTWINS T
WHERE T.$dtId = 'Room1'

Here's an example using a function. The following query uses the IS_OF_MODEL function to specify in the WHERE clause to only return the twins with a model of dtmi:sample:Room;1. For more about the IS_OF_MODEL function, see Azure Digital Twins query language reference: Functions.

SELECT *
FROM DIGITALTWINS
WHERE IS_OF_MODEL('dtmi:sample:Room;1')