2014-03-27 28 views
1

專門針對Python和Web2py的新手。有困難要轉換爲DAL此:將帶有子查詢的Mysql查詢轉換爲web2py DAL可能嗎?

select t.id, t.gp_pro_id, t.gp_historicdate 
from course t where t.gp_historicdate = 
(select MAX(a.gp_historicdate) 
from course a where a.id = t.id) 

任何幫助將不勝感激。我只是不想使用executesql,但如果它不可能翻譯,那麼我會。

謝謝!

+0

你能提供有關'course'表的結構的詳細信息? – omar

回答

0

小菜一碟!

db(db.course.gp_historicdate == db.course.gp_historicdate.max()).select(db.course.id, db.course.gp_pro_id, db.course.gp_historicdate) 

Check the official documentation