TheAlbear
TheAlbear

Reputation: 5595

Joining multiple DBs in mySql, user credential issue

I am joining two DB together to complete a query.

$strSQL = "SELECT tbl.SecurityKey,
                  tbl.method,
                  tbl.amount,
                  tbl.TxType,
           CONCAT(u.firstname,' ',u.lastname) AS fullname 
           FROM $CFG->paymentdbname.tblPayment tbl 
           JOIN $CFG->dbname.vle5_user u 
           ON u.id = " . $uid . " 
           WHERE VendorTxCode='" . mysql_real_escape_string($strVendorTxCode) . "' and VPSTxId='" . mysql_real_escape_string($strVPSTxId) . "'";

The issue that I am having is that each DB has its own user and so when I try to run the query with either user it fails as the user dosen't have the right privileges.

I had a good hunt around in the Plesk control panel as I though the answer might be to have a DB user with access to both, but this don't seem to be an option.

Upvotes: 3

Views: 144

Answers (1)

Nimit Dudani
Nimit Dudani

Reputation: 4860

You can deal with multiple DB in single sql query only if user connected by mysql_connect is permitted to access both DB.

Go to your control panel and add all privilege to user X for DB A and B. after this you can use two different DB in single Sql

Upvotes: 3

Related Questions