Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Multiple Joins in Codeigniter in PHP
WhatsApp
Bhushan Singh
Jan 01
2015
5.8
k
0
0
$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();
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();
join table
PHP
Up Next
Multiple Joins in Codeigniter in PHP