sql - How to join a query as a tabel in laravel form? -
like this:
select * `teachers` t1 join (select round(rand() * ((select max(id) `teachers`)-(select min(id) `teachers`))+(select min(id) `teachers`)) id) t2 t1.id >= t2.id order t1.id limit 20;
you can try raw in join.
teacher::select( '*', )->join( db::raw(select round(rand() * ((select max(id) `teachers`)-(select min(id) `teachers`))+(select min(id) `teachers`)) id) ) t2, t1.id >= t2.id ) ->orderby('t1.id') ->get();
Comments
Post a Comment