我尝试加入两个查询来比较使用代码点火器(ci)的学生两个学期的结果。
我可以直接用mysql来做,但是如何用ci来做呢?
以下是对mysql的查询:
select x.student, x.2017, y.2018 from (SELECT a.student_id student, sum(a.marks) 2017 FROM a a
WHERE a.year = '2017' GROUP by student
) x
LEFT JOIN
(SELECT b.student_id student, sum(b.marks) 2018 FROM b b
WHERE b.year = '2018' GROUP by student
) y on x.student = y.student
如何在ci中实现这一点?
1条答案
按热度按时间31moq8wy1#
试试这个,希望有用。