Hey everyone,

sorry for the title, I couldnt think of any way to describe this in
short.
I have 3 Classes, which have basically this relationship:

1 Class1 has n Class2 ( 1:n)
1 Class2 has n Class3 ( 1:n)

So basically it looks like this:

Class1
  |-- Class2
           |-- Class3

Now if I join them all together, i get something like this:

Class1     Class2       Class3
--------------------------------------
    1              1              1
    1              1              2
    1              2              1
    1              2              2
    2              1              1
    2              1              2
    2              2              1
    2              2              2
.... etc

so if I loop through the results i would have something like this:

  for (class1, class2, class3) in results:
        print class1, class2, class3

But what I would really like to do is:

for (class1, class2_results) in class1:
       print "results for class1:
       for (result, class3_results) in class2_results:
               print "results for class2:"
               for result in class3_results:
                      print "result"

which will give me an output more like this:


results for class1:
        result1
        results for class2:
                result1
     ....

And so on.
In short, I want to get get xxx rows of class1 repeating, but I want
to get one result per class1, containing nested results.

Is that possible and do I need subqueries for that?

Greetings,

Tom

--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to