Two tables:
Table One: Pre_company_member Association fields: comp_id
Table II: Pre_company Associated fields: comp_id
Query the data in both tables.
Method One: Hump method
$member =m (' Companymember ');
$member _info= $member->join (' Pre_company on pre_company_member.comp_id=pre_company.comp_id ')->where (Array (' Pre_company_member.uid ' =>array (' EQ ', session (' UID '))))->selsect ();
Method Two: Alias method
$member =m ();
$member _info= $member->table (' pre_company_member m ')->join (' Pre_company C on m.comp_id=c.comp_id ')->where ( Array (' M.uid ' =>array (' EQ ', session (' UID '))))->selsect ();
Attention:
The default is the inner join method, if you need to use a different join method, you can change to
$Model->join(‘RIGHT JOIN __WORK__ ON __ARTIST__.id = __WORK__.artist_id‘)->select();
or use:
$Model->join(‘__WORK__ ON __artist__.id = __WORK__.artist_id‘,‘RIGHT‘)->select();
The type of support for the second parameter of the Join method includes: INNER left-right-full.
the Join method can only be used once if the parameters of the join method are in an array, and cannot be mixed with the string method. For example:
join(array(‘ __WORK__ ON __ARTIST__.id = __WORK__.artist_id‘,‘__CARD__ ON __ARTIST__.card_id = __CARD__.id‘))
in the case of array mode, the second argument is invalid. The join type must therefore be explicitly defined in the string , for example:
join(array(‘ LEFT JOIN __WORK__ ON __ARTIST__.id = __WORK__.artist_id‘,‘RIGHT JOIN __CARD__ ON __ARTIST__.card_id = __CARD__.id‘))
Join method for thinkphp