# How to combine two tables and filter based on one tables field

**URL:** <https://community.influxdata.com/t/how-to-combine-two-tables-and-filter-based-on-one-tables-field/25093>\
**Category:** InfluxDB 2\
**Tags:** influxdb, query, flux\
**Created:** [May 19, 2022, 6:55am UTC](https://community.influxdata.com/t/how-to-combine-two-tables-and-filter-based-on-one-tables-field/25093 "2022-05-19T06:55:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Petrov](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/alexander_petrov/32/10180_2.png) [@Alexander\_Petrov](https://community.influxdata.com/u/Alexander_Petrov)\
**Post date:** [May 19, 2022, 6:55am UTC](https://community.influxdata.com/t/how-to-combine-two-tables-and-filter-based-on-one-tables-field/25093/1 "2022-05-19T06:55:52Z")

</div>

I am curious to ask. I have two tables one stores logntitude and latitude as floats and another one that stores the device\_id as uuid. The thing I want to achieve is write a query which will give me the values longtitude and latitude for a specific device\_id as input. How can I combine these two tables, they are stored in the same bucket animal\_logs? The measurement is called animal-data and they are inputted at the same time. Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![Ravikant\_Gautam](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ravikant_gautam/32/5700_2.png) [@Ravikant\_Gautam](https://community.influxdata.com/u/Ravikant_Gautam)\
**Post date:** [May 20, 2022, 5:20am UTC](https://community.influxdata.com/t/how-to-combine-two-tables-and-filter-based-on-one-tables-field/25093/2 "2022-05-20T05:20:03Z")

</div>

> [@Alexander\_Petrov](#):
>
> uuid

If you want to join two tables then there should be at least one common field in both tables and based on that variable you can combine two tables and store the result in different measurements and after that, you can perform on the new table.

---

<div class="post-metadata">

**Author:** ![Alexander\_Petrov](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/alexander_petrov/32/10180_2.png) [@Alexander\_Petrov](https://community.influxdata.com/u/Alexander_Petrov)\
**Post date:** [May 22, 2022, 7:59am UTC](https://community.influxdata.com/t/how-to-combine-two-tables-and-filter-based-on-one-tables-field/25093/3 "2022-05-22T07:59:12Z")

</div>

Is it possible to group by \_time, also can you provide me with some sample code on how to combine tables and then extract information from them. Thank you!

---

<div class="post-metadata">

**Author:** ![Ravikant\_Gautam](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ravikant_gautam/32/5700_2.png) [@Ravikant\_Gautam](https://community.influxdata.com/u/Ravikant_Gautam)\
**Post date:** [May 24, 2022, 11:50am UTC](https://community.influxdata.com/t/how-to-combine-two-tables-and-filter-based-on-one-tables-field/25093/4 "2022-05-24T11:50:03Z")

</div>

> **[join() function | Flux 0.x Documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/join/)**
>
> join() merges two streams of tables into a single output stream based on columns with equal values. Null values are not considered equal when comparing column values. The resulting schema is the union of the input schemas. The resulting group key is...

Here, it’s explained very clearly how to do join two tables
