I want to do joins on the table from two DBS.
What I did is.
var mysql = require('mysql');
var poolCluster = mysql.createPoolCluster();
var configDB=require('../config');
let config={};
config['settlement']={...configDB['settlementDB']};
config['vch']={...configDB['vchSystemDB']};
poolCluster.add('settlement', config['settlement']); // add a named configuration
poolCluster.add('vch', config['vch']);
let query="SELECT * from settlement.VoucherAndSettlementDetails VoucherAndSettlementDetails JOIN vch.voucher voucher on VoucherAndSettlementDetails.voucherId = voucher.vchid "
poolCluster.getConnection(function (err, connection) {
if(err) console.log("error poll connection",err);
connection.query(query, function (error, results, fields) {
console.log("fields ",fields)
console.log("results ",results)
if (error){
console.log('error is ',error);
return;
}
});
});
I am getting following Error :
code: 'ER_NO_SUCH_TABLE',
errno: 1146,
sqlMessage: "Table 'vch.voucher' doesn't exist"
Can someone help me to do it? I am not understanding on which connection object query should be performed.