I have 2 databases needs to be joined.
Here is the query that I have but the $db2
is only for the 2nd database, and $this->db->query
only for 1st database.
$akses = $db2->query("select A.uName, A.userPwd, A.[Nomor Induk], B.id_jabatan, B.nama FROM tUser A
LEFT JOIN karyawan B ON B.nik = A.[Nomor Induk]
LEFT JOIN bagian_departemen C ON C.id_bagian_dept = B.id_bagian_dept
WHERE A.uName = '$username' AND A.userPwd = '$password'"
);
I want to know the syntax to join 2 table from 2 databases.
Databases:
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'helpdesk',
'dbdriver' => 'sqlsrv',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'striction' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['another_db'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'produksi',
'dbdriver' => 'sqlsrv',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'striction' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);