Create a Insert… Select statement in Laravel

前端 未结 6 1188
迷失自我
迷失自我 2020-12-11 14:41

I\'m needing to convert this query for Laravel and I\'m having issues trying to create an Insert... Select statement using Laravel\'s Eloquont ORM, or Queries. I\'m not sure

6条回答
  •  忘掉有多难
    2020-12-11 15:14

    Try this

    DB::table(table2)
        ->insert(
            (array) DB::table(table1)
                ->where('column', '=', $variable)
                ->select('column1','column2')
                ->first()
        );
    

提交回复
热议问题