GuidesPublished

How to Join Data From Two Different Databases (Without an Engineer)

Your customers are in one database and your payments in another. Here are three honest ways to join them, and what to check before you trust the answer.

Gaurav Kunal6 min read

Simplifying AI

Picture a Monday morning. Your manager asks a simple question: "How many of the customers who joined us this year have still not paid us anything?" You know the company has this information. And yet nobody can answer it by evening.

Here is why. The list of customers — who they are, when they joined, which plan they chose — is stored in one database, because the sales team's software put it there. The payments are stored in a different database, because the finance system was set up two years later, by different people. It is true that every payment record names the customer who paid. But a customer who has never paid does not appear in the payments database at all — that database has no record of the person, so it cannot tell you who is missing. The only way to find those customers is to put the two lists side by side and see who is on the customer list but not on the payments list. The question needs both databases at once, and neither one holds the whole answer.

This situation has a name: you need to join data from two different databases. This post explains why that is genuinely hard, the three honest ways teams do it today, and what to check before you trust any answer that comes from two systems — plus a newer way that skips the engineering work completely.

Why two databases cannot talk to each other

A single database can combine two of its own tables within a second. That is easy for it, because both tables are stored inside it: everything is in one place, and one program is matching its own data.

Two separate databases do not have this advantage. They are two independent programs, often running on two different servers, and neither one knows that the other exists. Neither can read the other's records. So when an answer needs a customer record from one database and a payment record from the other, a third program has to do the job — a program that stands outside both databases. It takes the customer records from the first database, takes the payment records from the second, and matches them together.

Building and running that third program is the real work. There are three common ways to do it, and they cost very different amounts of your time.

A customers database in MySQL and a payments database in PostgreSQL, with the email column highlighted in both and joined by a dashed line labelled join key, under the question: which customers joined this year but never paid?
The two databases hold different halves of the answer, and the email column is what links them.

Way one: export both, match them by hand

You export the customers into a spreadsheet, export the payments into a second spreadsheet, and match the two with a lookup formula (like VLOOKUP in Excel).

For a one-time question, this is honestly fine — it needs no engineer and no new software. The problem appears later: the result does not update itself, so it is correct only on the day you made it. Next month the same question returns, the whole exercise repeats, and every repeat is a fresh chance for a silent mistake — this month's export arranges its columns in a different order, your formula reads the amount from the wrong column, and the spreadsheet still fills up with numbers, so nothing looks wrong. Teams that answer a monthly question this way lose hours every month, and nobody ever counts the total.

Way two: copy everything into one place

The classic engineering answer is to stop joining across databases and instead move the data: copy both sources, on a schedule, into one central "warehouse" database, so that everything is finally stored together.

For a company with a data team, this is the right long-term answer — it is how large organisations solve the problem. The cost is that it is a project, not a task: it takes weeks or months, not an afternoon. Someone must build the copying process, make sure it runs every night without failing, and repair it whenever one of the source databases changes — for example, when the sales software gets an update and renames a column the copier was depending on. Until that project is finished, your Monday question stays unanswered.

Many databases can be connected to each other directly. PostgreSQL has a feature that lets it read another database; SQL Server has one too. Once an engineer sets it up, one query can read both sides.

The cost here is smaller but real: you need administrator access, and a person who is comfortable setting it up. And there is one more condition, the one that stops most teams — this method generally works only when both databases are the same kind. That brings us to a situation almost nobody writes about.

The common case nobody covers: two different kinds of database

Guides on this topic usually answer for one database type at a time. PostgreSQL guides explain the PostgreSQL method. SQL Server guides explain the SQL Server method.

But in real companies, the customer database is often MySQL and the payment database is PostgreSQL — two different kinds, bought at different times by different teams. The same-kind method does not work here. The warehouse project would take months. And the person who needs the answer works in operations, not in engineering.

This exact gap is why we built cross-database questions into ChatPlotDB.

A newer way: ask both databases one question in English

With ChatPlotDB, you connect each database once. Then you group two to five of them so that they behave like a single database, and you ask the group your question in plain English: "which customers joined this year but never paid?"

You do not see the next part, but this is what happens: ChatPlotDB asks each database separately, in that database's own language, then brings the records together and matches them.

Nothing is copied anywhere, so there is no warehouse to build and nothing to keep updated — every answer reads the live data at the moment you ask. And the databases do not need to be the same kind: a MySQL database, a PostgreSQL database and a DynamoDB table can all be in one group together.

The one safety decision that matters most

To match records across two databases, the system needs a join key: a column that exists on both sides and holds the same value for the same customer — the email address, for example. Guessing that key is easy. Guessing it wrong is dangerous, because a wrong key still produces a confident-looking answer — an answer built from records that were never actually related.

So ChatPlotDB refuses to guess. Before a join key is saved, it proves against both live databases that the column really exists, and during setup it also samples real values from both sides to check that they actually overlap. If it cannot prove a key, it says so and refuses — it will not save something that only looks right. It also handles the small mismatches that break real joins — one system stores "Ravi@Company.com", another stores "ravi@company.com", and a computer comparing letter by letter treats those as two different values even though every human knows they are the same person. ChatPlotDB cleans both sides before comparing, so they match the way a human would match them.

And every question runs in read-only mode, which means ChatPlotDB can look at your data but can never change it or delete it.

Which way should you choose?

If you need the answer once, export both sides and match them by hand — for a single question, it is genuinely the cheapest option. If you need the answer every month and you have a data team, the warehouse is worth building. And if you need it every month but have no data team — and most growing companies are in exactly this situation — then ChatPlotDB was built for you. Connect the databases you already have, ask your question in English, and get an answer that is honest about what it matched.

Quick answers

Can I join data from two databases without moving the data?

Yes. Either an engineer links the databases directly, or a tool like ChatPlotDB queries both live databases and matches the results — no copying, no warehouse.

Can I join a MySQL database with a PostgreSQL database?

Yes, but not with the built-in same-kind methods. You need either a warehouse that both copy into, or a tool that speaks to each database in its own language and joins the results — ChatPlotDB does this with up to five databases at once.

What is a join key?

The column that holds the same value for the same customer in both databases — often an email address or a customer ID. It is how the two sides get matched, and that is why a wrong join key silently produces a wrong answer.

Is it safe to let a tool query my databases?

It should be read-only, meaning the tool can look but never change anything. ChatPlotDB runs every query read-only, and it can also show you each query for approval before the query runs.

Ask one question across all your databases — no SQL, no engineer

Related Articles

Browse all articles →