<分区>
我有一个数组 $time_schedule_id= array(1,3,5)。现在我想要那些与 $time_schedule_table 中的给定数组 ( $time_schedule_id= array(1,3,5) ) 不匹配的数据。
DB::table('time_schedule_table')
select('*')
where('id','!=', ?)
如何生成此查询字符串以用于 MySQL?
<分区>
我有一个数组 $time_schedule_id= array(1,3,5)。现在我想要那些与 $time_schedule_table 中的给定数组 ( $time_schedule_id= array(1,3,5) ) 不匹配的数据。
DB::table('time_schedule_table')
select('*')
where('id','!=', ?)
如何生成此查询字符串以用于 MySQL?
最佳答案
可以使用 laravel whereNotIn()
Eloquent 函数
DB::table('time_schedule_table')->select(*)->whereNotIn('id', [1,3,5])->get();
关于php - 如何在 Laravel 的 MySQL 查询中的 where 子句中使用数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49004805/