问题
I'm trying to query data based on tag values. Is it possible to include multiple queries in the where clause . I could not find an operator similar to the IN operator in SQL.
select * from students where rollNumber='1' limit 10
students is the measurement and rollNumber is a tag. I want include multiple values of rollNumber in the query.
Any suggestions to solve the problem?
回答1:
InfluxDB does not have IN operator, however it supports Go-lang regular expressions in WHERE clause for fields and tags. Regular expressions are enclosed with /
and require adding ~
after comparison operator:
select * from students where rollNumber =~ /1|2|3/ limit 10
This will return 10 students with rollNumber
1 or 2 or 3.
Note: In case of filtering fields, if the type of fields is not string, regex will not work...
来源:https://stackoverflow.com/questions/50983872/influxdb-including-multiple-values-in-where-clause-based-on-tags