LARAVEL 使用列表结果作为参数

LARAVEL use Lists result as a parameter

我需要一些帮助才能在 laravel 中执行此查询。

Select id from tableone where id in (1,2,3,4,5)

(1,2,3,4,5) 必须是另一个查询的结果。

 This >>> $s = TableOne::lists('id');
 Result >>> ["4","14", "11", "1", "13", "3", "2"]

我该怎么做?

您可以在 Laravel 中使用 wherein 功能。

$s = AnotherTable::lists('id'); // get ids from another query
$users = TableOne::whereIn('id', $s)->get(); // pass array of ids into it

更多信息:http://laravel.com/docs/5.0/queries#selects