# Querying multiple time points

**URL:** <https://community.influxdata.com/t/querying-multiple-time-points/35388>\
**Category:** Systems\
**Tags:** influxql\
**Created:** [August 20, 2024, 9:17pm UTC](https://community.influxdata.com/t/querying-multiple-time-points/35388 "2024-08-20T21:17:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lvn2007](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@lvn2007](https://community.influxdata.com/u/lvn2007)\
**Post date:** [August 20, 2024, 9:17pm UTC](https://community.influxdata.com/t/querying-multiple-time-points/35388/1 "2024-08-20T21:17:10Z")

</div>

Hello all,

I’m currently using influxcxx client library to interact with InfluxDB v1.6.7~rc0.  
In my code, I have querying a **single** datapoint by timestamp (Target time is 946684800) as:

```auto
SELECT * FROM BENCH_DB WHERE time = 946684800ms

```

However, as I progress towards creating a query for **multiple** datapoints by multiple **random** timestamps (This means that range query such as WHERE time \>= xxx AND time \<= xxx would not work either). Per my understanding it seems like InfluxDB does not support this type of query yet (Neither multiple OR operator or IN operator works).  
EX: I want to query for all data that matches this list of target timestamps (946684800, 946684801, etc.)

```auto
SELECT * FROM BENCH_DB WHERE (time = 946684800ms OR time = 946684801ms)

```

---

<div class="post-metadata">

**Author:** ![scott](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/scott/32/16492_2.png) [@scott](https://community.influxdata.com/u/scott)\
**Post date:** [August 20, 2024, 9:56pm UTC](https://community.influxdata.com/t/querying-multiple-time-points/35388/2 "2024-08-20T21:56:53Z")

</div>

@lvn2007 InfluxQL does not support the `OR` logical operator when using the `time` column (noted in the [documentation](https://docs.influxdata.com/influxdb/v1/query_language/explore-data/#syntax-1)). In newer versions of InfluxDB, this is still the same. This would be possible with Flux, but you’d have to use InfluxDB 1.7+ to have access to Flux.

Do you need to query by specific timestamps if the timestamps are random? Why not just use [`SAMPLE`](https://docs.influxdata.com/influxdb/v1/query_language/functions/#sample) to return N random points from a queried dataset?

---

<div class="post-metadata">

**Author:** ![lvn2007](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@lvn2007](https://community.influxdata.com/u/lvn2007)\
**Post date:** [August 20, 2024, 11:13pm UTC](https://community.influxdata.com/t/querying-multiple-time-points/35388/3 "2024-08-20T23:13:55Z")

</div>

Hi Scott, thanks for your reply.  
I’m not sure I understand your answer, perhaps you misunderstood my question.  
I would like to query a random timestamp. Though, the target timestamps are decided on my end, not from picking randomly by the SAMPLE call.

Essentially, I would like to query the same way as the below but instead of making each individual query at a time, I would send it as a batch of timestamps and wait for results to return.

```auto
SELECT * FROM BENCH_DB WHERE time = 946684800ms

```

---

<div class="post-metadata">

**Author:** ![scott](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/scott/32/16492_2.png) [@scott](https://community.influxdata.com/u/scott)\
**Post date:** [August 20, 2024, 11:42pm UTC](https://community.influxdata.com/t/querying-multiple-time-points/35388/4 "2024-08-20T23:42:15Z")

</div>

Gotcha. This isn’t possible with InfluxQL. InfluxQL doesn’t support the `IN` logical operator so you couldn’t pass a list or array. It also doesn’t support the `OR` operator on `time` values. I think the only way to do what you’re trying to do with the version of InfluxDB you’re using is to send a separate query per timestamp and combine the results client-side.

---

<div class="post-metadata">

**Author:** ![lvn2007](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@lvn2007](https://community.influxdata.com/u/lvn2007)\
**Post date:** [August 20, 2024, 11:48pm UTC](https://community.influxdata.com/t/querying-multiple-time-points/35388/5 "2024-08-20T23:48:14Z")

</div>

I suspect that was the case but thanks a lot for the confirmation.
