0
我有三个表与articles
相关,我需要从staff_id
我得到article_id
。Laravel数据库查询优化
我目前正在使用这三个查询。
$rejects = DB::table('rejected')->where('staff_id', $staff_id)->pluck('article_id');
$missed = DB::table('missed')->where('staff_id', $staff_id)->pluck('article_id');
$flagged = DB::table('flagged')->where('staff_id', $staff_id)->pluck('article_id');
,然后将它们合并
$rejects = $rejects->toArray();
$missed = $missed->toArray();
$flagged = $flagged->toArray();
$all = array_merge($rejects, $missed, $flagged);
在生产中我的数据库将在不同的服务器上,所以我试图减少无查询。 我怎样才能得到这个结果只使用一个数据库查询。
您是否尝试过使用连接语句? – hungrykoala
不同的服务器和不同的数据库,这是不可能的,没有特殊的设备。 – Amin