How to use IN clause in iot hub route query

2019-08-21 02:21发布

问题:

The following query is not working in route query: $body.Weather.Temperature in ['30','50']

I checked the documentation and the syntax looks right.

回答1:

IN and NIN (not in) operator it used to check the item is or isn't in the array constants like ['wired', 'wifi'].

For your case, you need use Comparison operator: >= and <= like this:

$body.Weather.Temperature >= 30 AND $body.Weather.Temperature <= 50

For detailed information you can reference "IoT Hub query language for device twins, jobs, and message routing".

Update:

For selecting the exact value 30/50 you can use the following query string as a workaround.

$body.Weather.Temperature = 30 OR $body.Weather.Temperature = 50