# Inner Join two tables from two database connections in query

**URL:** <https://forum.inductiveautomation.com/t/inner-join-two-tables-from-two-database-connections-in-query/10602>\
**Category:** Ignition\
**Created:** [October 9, 2015, 5:11pm UTC](https://forum.inductiveautomation.com/t/inner-join-two-tables-from-two-database-connections-in-query/10602 "2015-10-09T17:11:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerry101](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jerry101](https://forum.inductiveautomation.com/u/jerry101)\
**Post date:** [October 9, 2015, 5:11pm UTC](https://forum.inductiveautomation.com/t/inner-join-two-tables-from-two-database-connections-in-query/10602/1 "2015-10-09T17:11:15Z")

</div>

I need to inner join two different tables from different database connections. How would I do this in a query from say “database1”?

SELECT  
\*  
FROM  
table1 t1  
INNER JOIN  
dbConn2.database2.table2 t2 ON t1.Field = t2.Field

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [October 9, 2015, 5:57pm UTC](https://forum.inductiveautomation.com/t/inner-join-two-tables-from-two-database-connections-in-query/10602/2 "2015-10-09T17:57:25Z")

</div>

You cannot join using database connections.

If database2 is on the same server as database1, you can do this.

`SELECT
*
FROM
table1 t1
INNER JOIN
database2.table2 t2 ON t1.Field = t2.Field`

---

<div class="post-metadata">

**Author:** ![jerry101](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jerry101](https://forum.inductiveautomation.com/u/jerry101)\
**Post date:** [October 9, 2015, 6:15pm UTC](https://forum.inductiveautomation.com/t/inner-join-two-tables-from-two-database-connections-in-query/10602/3 "2015-10-09T18:15:35Z")

</div>

They are on different servers but I got it figured out, thanks!

SELECT  
\*  
FROM  
table1 t1  
INNER JOIN  
[SeverName].Database2.dbo.Table2 t2 ON t1.Field = t2.Field

---

<div class="post-metadata">

**Author:** ![kruse.andrew](https://avatars.discourse-cdn.com/v4/letter/k/919ad9/32.png) [@kruse.andrew](https://forum.inductiveautomation.com/u/kruse.andrew)\
**Post date:** [May 29, 2018, 2:49pm UTC](https://forum.inductiveautomation.com/t/inner-join-two-tables-from-two-database-connections-in-query/10602/4 "2018-05-29T14:49:27Z")

</div>

What is the proper syntax for referencing the server name?
