a SQL statement containing joins usually has the joins in a chain: select * from table1 JOIN table2 ON table1.somecolumn = table2.somecolumn JOIN table3 on table2.somecolumn=table3.somecolumn ...
SQLAlchemy's join function works in a similar way. you can keep calling "join" on the previous "join" in a generative fashion: j = table1.join(table2, table1.c.somecolumn==table2.c.somecolumn).join (table3, table2.c.somecolumn==table3.c.somecolumn) the above construct generates into just the "join" clause part of the SQL statement. but it is a "selectable", meaning its an element that contains its own list of columns and can be used in the FROM clause of a SELECT statement. when you have a selectable, you can select all columns by saying: j.select() or the selectable can be added to the FROM clause of any select using from_obj; s = select([table1.c.col1, table2.c.col2, ...], from_obj=[j]) using from_obj as above, you can combine the join with any other set of selectables. On Mar 15, 2007, at 7:13 PM, Gloria wrote: > > Hi All, > Good examples of rudimentary joins of 3 or more tables are hard to > find. Please point me to some decent examples. > Thank you, > ~G~ > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---