Codeigniter Active Records:
$this->db->select('*'); $this->db->from('TableA AS A');// I use aliasing make things joins easier $this->db->join('TableC AS C', 'A.ID = C.TableAId', 'INNER'); $this->db->join('TableB AS B', 'B.ID = C.TableBId', 'INNER'); $result = $this->db->get();
Custome MySql Query
SELECT * FROM TableA AS A INNER JOIN TableC AS C ON C.TableAId = A.ID INNER JOIN TableB AS B ON B.ID = C.ID
Your can also write Mysql Query Under Active Records Method:
$this->db->query();
$this->db->query("SELECT * FROM TableA AS A INNER JOIN TableC AS C ON C.TableAId = A.ID INNER JOIN TableB AS B ON B.ID = C.ID");
$this->db->query(); Utilizes mysql_query();
0 comments