Relating the two fields into one record - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Relating the two fields into one record (/showthread.php?tid=54138) |
Relating the two fields into one record - El Forum - 08-24-2012 [eluser]konradinho[/eluser] Hi there. My table looks like this: Table match id team_1 team_2 Table club id team_name How to combine these tables and then refer to them in this way: Code: $item->team_name_1; I tried to call the function: Code: $this->db->join('club', 'club.id = match.team_1 and club.id = match.team_2'); But it did not work. You can also break it into two functions, one gets the data on one team and one on the second team But I wanted to do it in one function. Thank you in advance for your help. Relating the two fields into one record - El Forum - 08-24-2012 [eluser]Otemu[/eluser] Hi, Do your join like this: Code: $this->db->join('club as idt1', 'idt1.club = match.team_1'); Hope that helps |