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

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -