在Laravel中左连接内的find_in_set

问题描述:

如何在Laravel查询构建器中使用find_in_set().这是我的原始查询:

How can I use the find_in_set() with laravel query builder. Here is my raw query:

SELECT *
FROM table1 as t1
  LEFT JOIN table2 as t2 ON find_in_set(t2.country, t1.fk_country_id)

您可以使用 DB::raw 就像

You can use DB::raw like as

DB::table('table1')->leftJoin('table2', function($join){
   $join->on(DB::raw("find_in_set(table2.country, table1.fk_country_id)",DB::raw(''),DB::raw('')));
});