2

I have to try two joins but this is not going to work. code in Codeginator.

$this->db->select('concat(firstName," ",lastName) as fullnameVisitor,users.firstName,visitorId,destinationId,count,activityStatus,created,updated');
    $this->db->from('interestedprofile');
    $this->db->join('users','users.userId=interestedprofile.visitorId','LEFT');
    $this->db->join('users','users.userId=interestedprofile.destinationId','LEFT');
    $this->db->join('interestedprofile','interestedprofile.destinationId=users.userId','LEFT');
    $this->db->order_by('created','desc');
    return $this->db->get()->result_array();

User Table : https://i.sstatic.net/ppM3s.png Interest Table : https://i.sstatic.net/EbQIX.png

i have to find visitedid and destinationid users firstName and lastName in Users Table.

2 Answers 2

1

You don't have to use the Active Record fully to do the joins. You can use regular SQL. For example,

$query = $db->query("SELECT * FROM users;");

foreach ($query->getResult('User') as $user)
{
    echo $user->name; // access attributes
    echo $user->reverseName(); // or methods defined on the 'User' class
}
Sign up to request clarification or add additional context in comments.

1 Comment

codeselect us1.firstName,us2.firstName from interestedprofile ip join users us1 on us1.userid = ip.visitorId join users us2 on us2.userId = ip.destinationId code this query will be work. thanks
0

This Code is Work For me.

Select us1.firstName,us2.firstName from interestedprofile ip join users us1 on us1.userid = ip.visitorId join users us2 on us2.userId = ip.destinationId 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.