Mysql
 sql >> Database >  >> RDS >> Mysql

Unisciti a Laravel e seleziona da più tavoli

In questo caso (se le tabelle non sono correlate) dovresti usare union, no join.

$books = DB::table('books')->select('title')->where('year', 1994);
$journals = DB::table('journals')->select('title')->where('year', 1994);
$titles = DB::table('newspapers')->select('title')->where('year', 1994)->union($books)->union($journals)->get();