11.query数据查询基本篇三
约 260 字小于 1 分钟
前面介绍了两篇influxdb的查询基本操作姿势,然后有些小伙伴在实际的使用过程中,发现了一些有意思的问题,这里单独开一篇进行说明
1. select tag 无返回
select的查询语句格式定义如下
select "<field_key>"::field,"<tag_key>"::tag from xxx
当我们查询字段中,只有tag时,就会发现啥都没有

当我们需要查询tag value值时,请使用下面的方式
show tag values from measurements on key="tagKey"
如下

2. distinct(tag) 无返回
distinct函数主要用于去重,但是请注意函数内的只能是field,不能是tag,官方文档有说明

3. 模糊查询
influxdb的查询条件支持正则表达式,无论是tag,还是field都是可以的
语法如下
where [tagName|fieldName]=~/xxx/
演示如下

Loading...