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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -