2014-03-27 30 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