[英]Writing the correct SQL statement in AWS IoT rule
I am working on AWS IoT to develop my custom solution based on a set of sensors, and I have a problem regarding how to write the SQL statement related to the kind of data I receive from a Zigbee sensor.我正在使用 AWS IoT 开发基于一组传感器的自定义解决方案,但我有一个关于如何编写与我从 Zigbee 传感器接收的数据类型相关的 SQL 语句的问题。
An example of what I receive from my sensor is reported here:此处报告了我从传感器收到的示例:
{
"type": "reportAttribute",
"from": "WIFI",
"deviceCode": "aws_device_code",
"to": "CLOUD",
"mac": "30:ae:7b:e2:e1:e6",
"time": 1668506014,
"data": {...}
}
What I would like to do is to select messages that have the from
field equal to GREENPOWER
, something along the lines of SELECT * FROM 'test' WHERE from = 'GREENPOWER'
, but from
is also a keyword in SQL hence my problem.我想做的是 select 消息,其
from
字段等于GREENPOWER
,类似于SELECT * FROM 'test' WHERE from = 'GREENPOWER'
,但from
也是 SQL 中的关键字因此我的问题。 I am no expert whatsoever in SQL, so I am not sure how this can be done.我不是 SQL 方面的专家,所以我不确定如何做到这一点。 I am also looking for a way to modify the received data, but solving this problem on AWS would be much easier.
我也在寻找一种方法来修改接收到的数据,但在 AWS 上解决这个问题会容易得多。
Thank you very much for your help!非常感谢您的帮助!
There are quite a lot of SQL functions that exist in AWS IoT Rule. AWS IoT Rule 中存在相当多的 SQL 函数。 You can find them here: https://docs.aws.amazon.com/iot/latest/developerguide/iot-sql-functions.html
您可以在这里找到它们: https://docs.aws.amazon.com/iot/latest/developerguide/iot-sql-functions.html
In your case, something like this should work:在你的情况下,这样的事情应该有效:
SELECT * FROM 'test' WHERE get(*, "from") = "GREENPOWER"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.