mysql - 将原始数据库查询转换为 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/
任何帮助表示赞赏。
解决方案
推荐阅读
- reactjs - 如何渲染具有相同路由的多个道具的多个组件?
- permissions - 我是否需要完整的 Google Drive 权限才能覆盖文件?
- r - R:如何增加标签和箱线图之间的距离
- javascript - 在javascript中使用当前URL作为外部API参数的最佳方法
- flutter - AssetImage 在热重载之前不会在 iOS 上更新
- c++ - C++ 积分逼近 - For 循环函数加法
- php - 微服务客户端循环依赖
- python - 对数据集进行分层,同时避免索引污染?
- c# - C# EF Core Web Api 扩展在实体上为空
- python - 为数据集中的行创建直方图,分类为 1 和 0