On May 23, 2009, at 5:58 AM, sniipe wrote:

>
> I wrote in my first post, that I am expecting result in SQL - close to
> this one "select
> e.id, e.type_id, tv.version as min_version, tv2.version as
> max_version
> from engines e join versions tv on(e.min_version_id=tv.id) join
> versions tv2 on(e.max_version_id=tv2.id) where '7.0.1.32' between
> tv.version and tv2.version;". I don't know how to call tables to check
> condition in between clause.

do it just like SQL:

tv = aliased(Version)
tv2 = aliased(Version)
query(Engine.id, Engine.type_id, tv.version.label('min_version'),  
tv2.version.label('max_version')).\
      join((tv, Engine.min_version_id==tv.id)).\
      join((tv2, Engine.max_version_id==tv2.id)).\
      filter(literal("7.0.1.32").between(tv.version, tv2.version))

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to