reterview data from two tables using inner join in cakephp

Posted by user3593884 on Stack Overflow See other posts from Stack Overflow or by user3593884
Published on 2014-06-01T15:22:43Z Indexed on 2014/06/01 15:24 UTC
Read the original article Hit count: 143

Filed under:
|
|
|

I two tables from database one as user(id,first_name,last_name) and the second table location(id,country). I need to perform inner join with this two tables and the list should display first_name,last_name,country with condition user.id=location.id I have written sql queries in cakephp

 $this->set('users',$this->User->find('list', array(
                'fields' => array('User.id', 'User.first_name','location.country'),
                array('joins' => array(array('table' => 'location',
                               'alias' => 'location',
                               'type' => 'INNER',
                               'conditions' => array('User.id = location.id')))))));

i get error -Unknown column 'location.country' in 'field list' Please help!

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql