php - LARAVEL MYSQL how to use natural JOIN -
i need return in collection paginate can return in array because query use natural join. how query using laravel collections :
select mensagens.* mensagens natural join ( select id_emissor, max(created_at) created_at mensagens id_receptor = ".$user_id." group id_emissor) t
i have used code:
$mensagem = \db::select( db::raw("select mensagens.* mensagens natural join ( select id_emissor, max(created_at) created_at mensagens id_receptor = ".$user_id." group id_emissor) t ") );
if want use query use -
\db::raw("select mensagens.* mensagens natural join ( select id_emissor, max(created_at) created_at mensagens id_receptor = ".$user_id." group id_emissor) t");
else can use eloquent also.
Comments
Post a Comment