Hi Simon

Thanks for your help.  It's amazing what a tiny hint in the right direction
can do..  Between these emails, I've made a proof on concept, and am now
implementing the code in the real app.   So easy when I'm not blocked by a
warped vision of what I'm doing.

Funny, looking back at the docs I can now clearly see TABLE.join.... T A B L
E.join, not query.join...    I'm SURE that wasn't there before....  ;-D

Thanks again.

Cheers
Warwick


On 5 October 2010 20:39, King Simon-NFHD78 <simon.k...@motorola.com> wrote:

> Warwick Prince wrote:
> >
> > Hi Simon
> >
> > Thanks for that - I knew it was something wrong with the approach but
> > simply could not pick it!    Back to the test bench for another go :-)
> >
> > Cheers
> > Warwick
> >
> > P.S.  OK - I have to ask - when and how (why?) do I do the .join on
> > the query? ;-)
> >
>
> In SQL, you can treat a query just like a table, so you can join 2
> queries together, or join a query to another table. For example:
>
> SELECT *
> FROM
>   (SELECT a, b FROM table_1) as q1
>     INNER JOIN
>   (SELECT c, d FROM table_2) as q2
>     ON q1.b = q2.c
>
> That example is not very helpful - it could easily be rewritten as a
> single SELECT, but I hope you see that the subqueries can be as
> complicated as you like.
>
> The object that you were originally producing with your 'q.join(price)'
> wasn't a Select object, but a Join - something that you can select from.
> You could write something like this:
>
> # JOIN the price table with a query on the products table:
> j = prod.select().join(price)
>
> # SELECT from that JOIN:
> q = select(<some_columns>, from_obj=[j])
>
> This almost certainly isn't what you wanted in your situation, but there
> are plenty of cases where subqueries are very useful.
>
> Hope that helps,
>
> Simon
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to
> sqlalchemy+unsubscr...@googlegroups.com<sqlalchemy%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
>

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

Reply via email to