【问题标题】:How to use an array in where clause in MySQL query in Laravel [duplicate]如何在 Laravel 中 MySQL 查询的 where 子句中使用数组 [重复]
【发布时间】:2018-08-06 20:55:13
【问题描述】:

我有一个数组 $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 一起使用?

【问题讨论】:

标签: php mysql arrays laravel


【解决方案1】:

可以使用 laravel whereNotIn() eloquent 函数

DB::table('time_schedule_table')->select(*)->whereNotIn('id', [1,3,5])->get();

【讨论】:

  • @Mr.Developer......绝对正确
猜你喜欢
  • 2018-11-17
  • 1970-01-01
  • 2019-09-20
  • 2015-02-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-05
相关资源
最近更新 更多