我有这个查询
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"]);
有什么建议吗?