Welcome Guest, Not a member yet? Register   Sign In
Relating the two fields into one record
#1

[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;
$item->team_name_2;

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.
#2

[eluser]Otemu[/eluser]
Hi,

Do your join like this:

Code:
$this->db->join('club as idt1', 'idt1.club = match.team_1');
  $this->db->join('club as idt2', 'idt2.club = match.team_2');


Hope that helps




Theme © iAndrew 2016 - Forum software by © MyBB