# Inner join two database grafana

**URL:** <https://community.grafana.com/t/inner-join-two-database-grafana/57625>\
**Category:** Developers & API\
**Tags:** mysql\
**Created:** [December 13, 2021, 4:03pm UTC](https://community.grafana.com/t/inner-join-two-database-grafana/57625 "2021-12-13T16:03:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericalm](https://avatars.discourse-cdn.com/v4/letter/e/dfb087/32.png) [@ericalm](https://community.grafana.com/u/ericalm)\
**Post date:** [December 13, 2021, 4:03pm UTC](https://community.grafana.com/t/inner-join-two-database-grafana/57625/1 "2021-12-13T16:03:51Z")

</div>

I want to make an inner join of 2 tables, but one is in x database and the other in Y database, that is, they are 2 different databases, in sql I solve it easily as follows:

SELECT \* FROM aoidata.produccion as aoi  
INNER JOIN smtdatabase.orden\_trabajo as smt  
ON aoi.op=smt.op

How do I do this query in grafana? if you only let me select only 1 data sourc

---

<div class="post-metadata">

**Author:** ![anon70503803](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@anon70503803](https://community.grafana.com/u/anon70503803)\
**Post date:** [January 6, 2022, 12:47am UTC](https://community.grafana.com/t/inner-join-two-database-grafana/57625/2 "2022-01-06T00:47:08Z")

</div>

> [@ericalm](#):
>
> if you only let me select only 1 data sourc

Are you saying that you have connected to a SQL database through grafana, but you can only query on of those? If so, you can add a second datasource of the same kind (say, MySQL) and then add two queries to the panel. After that, you could try merging the two tables using a transformation like the [merge transform](https://grafana.com/docs/grafana/latest/panels/transformations/types-options/#merge).

But maybe I misunderstand?

I would also search this forum for similar questions:

> [@PostgreSQL INNER JOIN Query](https://community.grafana.com/t/postgresql-inner-join-query/50765):
>
> Grafana v8.0.6 PostgreSQL 13 I am attempting to set up graphs from data contained in the DB tables using INNER JOIN. The query I have started with in pgAdmin 4 retrieves exactly what I am looking for. See snippet below. This is the query i am running in the query tool. Working PostgreSQL Query: SELECT tm.source, td.value, td.timestamp FROM trend\_view td INNER JOIN trend\_meta tm ON td.externallogid = tm.externallogid WHERE tm.source like ‘%PRTG%AC8%’ AND td.type = 0 ORDER BY tm.s…
