codeigniter table join

users table was in both from and join functions, so in sum you were joining 3 tables: users, users and users_profiles -> the 2 first have the same name -> error unique/alias table.

Try this (joining [users in from] on [users_profiles in join]):

$this->db->select('users.usrID, users_profiles.usrpID')
         ->from('users')
         ->join('users_profiles', 'users.usrID = users_profiles.usrpID');
$result = $this->db->get();

EDIT:

example:

To get users_profiles userpNick column:

$this->db->select('users.usrID, users_profiles.userpNick')
         ->from('users')
         ->join('users_profiles', 'users.usrID = users_profiles.usrpID');
$query = $this->db->get();

view:

<?php foreach($query->result() as $row): ?>
        <tr class="even gradeC">
            <td><?php echo $row->usrID</td>
            <td><?php echo $row->userpNick;?></td>
        </tr>
<? endforeach; ?>

Leave a Comment