Answer the question
In order to leave comments, you need to log in
How to make a left join query from two tables in different databases in node, postgres?
Hello!
There are two pools:
const pool = new Pool({
host: 'db',
user: 'postgres',
password: 'pass',
port: 5432,
database: 'main', // и такой же пул, только с другим именем. В общем объекта два
});
db(ТУТ использовать какой пулл?, второй или первой базы?).query(
'SELECT db1.users.name FROM db1.users LEFT JOIN db2.rating on db1.users.id=db2.rating.user_id'
)
Answer the question
In order to leave comments, you need to log in
It is forbidden. This is not mysql, postgres does not support cross-db queries
From physically different databases, this will not work, just take data from two databases with your hands and join it in the code.
Unless your data is not in two databases, but in one, but different schemes, but then there is nowhere for two connections to come from.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question