php - 在 Magento 中添加一个以 SQL 查询为表的连接
问题描述
我有这样的查询=>
select table1.id, table1.name,
sorted_table2.marks from table1 LEFT JOIN (select DISTINCT student_id, marks from table2 order by marks DESC ) sorted_table2 ON table1.id = sorted_table2.student_id;
如何将其转换为 magento?
$select->joinLeft( array('sorted_table2' => '(select DISTINCT student_id, marks from table2 orderby marks DESC AS sorted_table2)'),'table1.id = sorted_table2.student_id', '*');
这不起作用,因为它在查询中添加了“`”并将其视为表名。有没有办法可以做到这一点?谢谢!
解决方案
推荐阅读
- sql-server - SQL Server 中的联接和子查询
- multithreading - 为什么在这段代码中,await 不会阻塞 ui
- javascript - 如何使网页淡入淡出而不立即淡入(使用JQuery)
- python - 2D 数组的 median_absolute_deviation 抛出 AxisError: axis 1 is out of bounds for array of dimension 1
- python - 尝试从可选依赖项导入后出现 UnboundLocalError
- c - 如何创建名称为扫描字符串的文本文件?
- python - 我试图制作一个在 youtube 视频下发送评论的程序,而 send_keys() 问题突然出现
- swift - 如何通过将访问者从表格视图单元格中的文本字段添加到数组中来解决此问题?
- swift - SwiftUI 不从资产加载图像
- javascript - 为什么 `Function.prototype` 在控制台中只返回对 `Function` 的引用?