【问题标题】:Convert Mysql query with subquery to web2py DAL possible?可以将带有子查询的 Mysql 查询转换为 web2py DAL 吗?
【发布时间】:2014-05-06 19:33:38
【问题描述】:

特别是 Python 和 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,但如果无法翻译,我会使用。

谢谢!

【问题讨论】:

  • 能否详细介绍course表的结构?

标签: sql select web2py data-access-layer


【解决方案1】:

小菜一碟!

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

【讨论】:

    猜你喜欢
    • 2012-05-12
    • 2014-10-11
    • 2013-07-17
    • 2014-07-12
    • 1970-01-01
    • 1970-01-01
    • 2011-06-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多