【问题标题】:(Laravel) What is Query Builder equivalent of this Postgresql query?(Laravel)这个 Postgresql 查询的查询生成器是什么?
【发布时间】:2014-10-01 10:03:57
【问题描述】:

我在 PostgreSQL 中有这个查询:

SELECT * FROM table1 LEFT JOIN table2 USING(col1, col2, col3) WHERE col1='value'

请帮我将其转换为 Laravel 中的查询生成器样式。

【问题讨论】:

    标签: sql postgresql laravel


    【解决方案1】:

    试试下面的代码。

    $data = DB::table('table1')
            ->join('table2', 'table1.col1', '=', 'table2.col1')
            ->join('table2', 'table1.col2', '=', 'table2.col2')
            ->join('table2', 'table1.col3', '=', 'table2.col3')
            ->where('col1', '=', 'value')
            ->get();
    

    【讨论】:

      猜你喜欢
      • 2019-03-29
      • 1970-01-01
      • 2015-12-13
      • 1970-01-01
      • 2011-02-28
      • 1970-01-01
      • 1970-01-01
      • 2020-01-30
      • 1970-01-01
      相关资源
      最近更新 更多