skip to main |
skip to sidebar
Multiple Joins in Codeigniter in PHP
Multiple Joins in Codeigniter in PHP
This code show Multiple Joins in Codeigniter.You can use this code in your projects to ease your work.
- $this->db->select('*');
- $this->db->from('TableA AS A');
- $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();
The join function works like this:
- join('TableName', 'ON condition', 'Type of join');
The equivalent SQL:
- $this->db->select('*');
- $this->db->from('TableA AS A');// I use aliasing make 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();
0 comments:
Post a Comment