是否可以连接来自不同数据库的两个表?
这是我的查询
public function getschedule($section){
$this->dbsections->select('*');
$this->dbsections->from($section);
//I want to join the column "teacher" of the "section_name" table that is in the "dbsections" database
//to the "id" column of the "teachers" table in the "dbusers" database
$this->dbsections->join('teachers', 'teachers.ID = '.$section.'.TEACHER');
$query = $this->dbsections->get();
$query = $this->dbsections->get();
return $query->result_array();
}
很明显,这个代码给了我错误。我也试过
$this->dbsections->join('dbusers.teachers', 'teachers.ID = '.$section.'.TEACHER');
和
$this->dbsections->join('dbusers.teachers', 'teachers.ID = dbsections.'.$section.'.TEACHER');
但两者都给了我错误
错误编号:1096
没有使用的表格
选择*
选择*时需要table name
作为
$this->dbsections->select("$section.*");// write tour table name before *
并删除一次
// $query = $this->dbsections->get();