[sqlalchemy] Re: Nested selects

2007-09-20 Thread Rick Morrison
Yes, those are called subqueries; they're fully supported by SA. Your query
above has a couple of items of note:

 a) it's a correlated subquery: the inner query references items in the
outer query. (supported by SA)
 b) it's a self-join: the inner query and outer query reference the same
table. (also supported by SA)

your query roughly translates into:

  p2 = p.alias()
  select([p.c.id], p.c.number == select(func.max(p2.c.number),
p2.c.attribute == p.attribute))

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Nested selects

2007-09-20 Thread Bruno Rezende
Thanks! I'll try it!

On 9/20/07, Rick Morrison [EMAIL PROTECTED] wrote:

 Yes, those are called subqueries; they're fully supported by SA. Your
 query above has a couple of items of note:

  a) it's a correlated subquery: the inner query references items in the
 outer query. (supported by SA)
  b) it's a self-join: the inner query and outer query reference the same
 table. (also supported by SA)

 your query roughly translates into:

   p2 = p.alias()
   select([p.c.id ], p.c.number == select(func.max(p2.c.number),
 p2.c.attribute == p.attribute))


 



-- 
um abraço,
Bruno

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~--~~~~--~~--~--~---