如何在Laravel中使用IN查询?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在Laravel中使用IN查询?相关的知识,希望对你有一定的参考价值。

In Laravel you can use "IN" query as

Using Eloquent

$data = YourModel::whereIn('id', array(1, 2, 3))->get();
Using DB Query builder

$data = DB::table('your_table')->whereIn('id', array(1, 2, 3))->get();
  1. In Laravel you can use "IN" query as
  2.  
  3. Using Eloquent
  4.  
  5. $data = YourModel::whereIn('id', array(1, 2, 3))->get();
  6. Using DB Query builder
  7.  
  8. $data = DB::table('your_table')->whereIn('id', array(1, 2, 3))->get();

以上是关于如何在Laravel中使用IN查询?的主要内容,如果未能解决你的问题,请参考以下文章