原生sql转laravel写法
$data = \DB::table('categories AS t')
->selectRaw('t.*,IFNULL(category_id,0) AS checked')
->where('parent_id', '>', 0)
->leftJoin(\DB::RAW("(SELECT * FROM sale_categories WHERE sale_id={$id}) AS t1"), 't1.category_id', '=', 't.id')
->get();
这里的\DB::RAW("(SELECT * FROM sale_categories WHERE sale_id={$id}) AS t1")怎样用laravel写吖?
麻烦大家帮帮忙!
谢谢啦!
No Comments