php - CodeIgniter how to sort joined record -
i have following query in codeigniter:
$user = $this->db ->select('users.*, login_logs.ip_address, login_logs.date, login_logs.userid') ->from('db.users') ->join('db.login_logs', 'users.userid = login_logs.userid') ->group_by('users.userid') ->get() ->result_array();
it works have select last record each user( in login_logs table) i'm getting first record. have tried :
->order_by('login_logs.idlogin_logs', 'desc')
but didn't work.
i have no idea how it. there easy way reach it?
@edit
i have triend asc/desc. no changes.
present query:
select `users`.*, `login_logs`.`ip_address`, `login_logs`.`date`, `login_logs`.`userid` `db`.`users` join `db`.`login_logs` on `users`.`userid` = `login_logs`.`userid` group `users`.`userid`
Comments
Post a Comment