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