【问题标题】:Use SELECT database laravel使用 SELECT 数据库 laravel
【发布时间】:2017-08-15 08:16:45
【问题描述】:

我的数据库有问题,请帮助我

select *from `parts` 
    where `code` in ('2976', '1620', '1619', '2977') 
    and `date` != '0000-00-00 00:00:00' 
    group by `code` 
    order by `created_at` desc

【问题讨论】:

  • 你忘了告诉我们问题是什么,伙计。
  • 我该怎么办

标签: mysql database laravel


【解决方案1】:

如果你只是想利用 Laravel 的 Query Builder 来做到这一点,就这么简单:

Illuminate\Support\Facades\DB::table('parts')
    ->whereIn('code', [2976, 1620, 1619, 2977])
    ->where('date', '!=', '0000-00-00 00:00:00')
    ->groupBy('code')
    ->orderBy('created_at', 'desc')
    ->get();

虽然你应该have a look over the documentation, it's all explained here clearly

【讨论】:

  • 我把它添加到任何文件中
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-03-16
  • 2021-04-07
  • 1970-01-01
  • 2021-02-15
  • 2020-08-16
  • 1970-01-01
  • 2018-05-28
相关资源
最近更新 更多