Distinct tables in Codeigniter

Asked

Viewed 23 times

0

I have a table where I save the idaluno and idconcedente, I want to make a select that picks the two ids go in their respective tables and take the alunonome and nomeconcedente. As in the codeigniter?

  • 1

    Edit the question and put the code you’ve tried to do and where it’s struggling

1 answer

0


In your model, you can do it this way:

function get_lista(){
    $this->db->select('concendente.nome as nome_concedente, aluno.nome as nome_aluno, tabela.*');
    $this->db->join('concendente', 'tabela.idconcendente=concendente.id');
    $this->db->join('aluno', 'tabela.idaluno=aluno.id');
    return $this->db->get('tabela')->result();
}

In this way, we make two joins, seeking the concrete table and the student table, and in select we define the name of each one.

  • 1

    Thank you, I did as you said and gave the result I wanted.

  • @davidsonAlves great, only accepts my reply as valid. Thank you! :

Browser other questions tagged

You are not signed in. Login or sign up in order to post.