php - Mysqli join tables from 2 different databases -
how can use 2 connections run query joins 2 tables? yesno.table1 , sushi.table1 ? lets join id
both have same id. how can that?
// connect yesno database $this->yesno_db = new mysqli("red", "yesno", "***", "yesnotmp"); if ($this->yesno_db->connect_errno) { throw new exception('connection failed: '.$this->yesno_db->connect_error); } // connect sushi database $this->sushi_db = new mysqli("red", "sushi", "***", "sushi"); if ($this->sushi_db->connect_errno) { throw new exception('connection failed: '.$this->sushi_db->connect_error); }
this question has nothing mysqli (or other api).
to join table different database, user connects mysql, have have select rights both databases.
having done, select 1 of databases in connection statement , address using usual dot syntax:
select * t1 join db2.t2
to answer question literally,
can use 2 connections run query joins 2 tables?
you can't
Comments
Post a Comment