【问题标题】:Query: Select distinct row in laravel查询:在laravel中选择不同的行
【发布时间】:2021-07-22 18:54:58
【问题描述】:

又是我…… 我有一个表格议程,在这个表格中我有列employee、hrbp 和direction。

如何获取 hrbp 为 HRBP1 的方向列表

 $ListDirectionHRBP1 = DB::table('agendas')->select('direction')->where('hrbp','=','HRBP1')->distinct()->get();

谢谢

【问题讨论】:

    标签: laravel select query-builder distinct-values


    【解决方案1】:
    $ListDirectionHRBP1 = DB::table('agendas')->where('hrbp','=','HRBP1')->select('direction')->get();
    

    【讨论】:

    • 谢谢。但我在查询中多次获得方向。我希望它准时在列表中
    【解决方案2】:

    你也可以试试这个:-

    $ListDirectionHRBP1 = DB::table('agendas')->where('hrbp','=','HRBP1')->select('direction')->get()->toArray();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-29
      • 1970-01-01
      • 2017-11-13
      • 1970-01-01
      • 1970-01-01
      • 2021-11-05
      • 1970-01-01
      相关资源
      最近更新 更多