I have two user and asset tables, and the foreign key is user_id . I want users to drill down and count each user asset. Therefore, I wrote a request as shown below, but did not receive the record. Please help me.
$ users = $ this-> select ()
-> from (array ('u' => 'users'),
array ('firstname'))
-> joinLeft (array ('a' => 'assets'),
'u.id = a.user_id',
array ('asset_per_user' => 'COUNT (a.id)'))
-> group ('u.id');
Jimit source
share