将原始数据库查询转换为Laravel查询生成器

时间:2020-05-21 11:04:33

标签: mysql sql laravel

在将此原始查询转换为Laravel查询生成器时遇到了一些问题:

\DB::select("
        select *
        from (
            select *,
            ROW_NUMBER() OVER(ORDER BY id) AS rownum
            from (
                select * from templates
                where industry_id = 2 and (palette_id = 1 OR palette_id = 2)
            ) as t1
        ) as t2
        WHERE (t2.rownum - 1) % 2 = floor(((t2.rownum - 1) / 2)) % 2
        ORDER BY t2.id"
    );

我尝试在此处进行转换,但出现了一些错误:http://cryptic-peak-77605.herokuapp.com/

感谢您的帮助。

0 个答案:

没有答案