# Select from two tables from different databases

**URL:** <https://forum.inductiveautomation.com/t/select-from-two-tables-from-different-databases/8103>\
**Category:** Ignition\
**Created:** [March 5, 2014, 11:55am UTC](https://forum.inductiveautomation.com/t/select-from-two-tables-from-different-databases/8103 "2014-03-05T11:55:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shv](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@shv](https://forum.inductiveautomation.com/u/shv)\
**Post date:** [March 5, 2014, 11:55am UTC](https://forum.inductiveautomation.com/t/select-from-two-tables-from-different-databases/8103/1 "2014-03-05T11:55:24Z")

</div>

Hi, I’m trying to join two tables from different databases. The query I’m using is:

`SELECT a.id, b.name
FROM db1.table1 a INNER JOIN db2.table2 b ON a.id = b.idUser `

where “db1” and “db2” are the name of the connections to each database. When I run the query using the Database Query Browser the following error appears:

[quote]GatewayException: ERROR: no existe el esquema «db1»  
caused by PSQLException: ERROR: no existe el esquema «db1»[/quote]

Any clues?,

Thanks

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [March 5, 2014, 3:37pm UTC](https://forum.inductiveautomation.com/t/select-from-two-tables-from-different-databases/8103/2 "2014-03-05T15:37:30Z")

</div>

Try making db1 and db2 the name of the database itself, rather than the name of the connection.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [March 5, 2014, 10:12pm UTC](https://forum.inductiveautomation.com/t/select-from-two-tables-from-different-databases/8103/3 "2014-03-05T22:12:47Z")

</div>

This will only work if they are two databases within the same database server. If they are different table’s from different database servers, you can’t do a join like this with a SQL query, unless your database server supports some sort of remote join.

---

<div class="post-metadata">

**Author:** ![shv](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@shv](https://forum.inductiveautomation.com/u/shv)\
**Post date:** [March 6, 2014, 10:27am UTC](https://forum.inductiveautomation.com/t/select-from-two-tables-from-different-databases/8103/4 "2014-03-06T10:27:55Z")

</div>

In my case there are different database servers. I’ll have to find another way to get what I want.

Thanks for the help.  
Regards
