如何使用Laravel Eloquent创建查询

时间:2019-07-12 21:55:29

标签: mysql laravel eloquent

我有这个查询

UPDATE series
  inner join(
             select @rownum:=@rownum+1  as live_rank, s.*
             from series s, (SELECT @rownum:=0) r
             WHERE nation_id = :nation and s.level = :level
             order by tsv_value desc) as r
SET series.rank = live_rank
WHERE series.id_serie = r.id_serie and series.nation_id = :nation

我必须在Laravel中使用它。

但是我不知道如何进行相同的加入:

   DB::table('series')
        ->join(DB::raw("select @rownum:=@rownum+1  as live_rank, s.*
          from series s, (SELECT @rownum:=0) r
          WHERE nation_id = ".$nation." and s.level = ".$level."
          order by tsv_value desc"),"r")<<<<<<<<<<<<<<<<<<<<?????
        ->where('series.id_serie', "=", "r.id_serie")
        ->where('series.nation_id', "=", $nation)
        ->update(['series.rank ' =>  "live_rank"]);

有什么建议吗?

0 个答案:

没有答案