The join works great now.  Thanks.

This query is actually being used for a subquery.  Table 'Time' also
has a column 'employeeId', which translates to an orm attribute of
'emp'.  When I add Time.emp to the columns of this subquery, all
columns of the 'Time' table are output instead of just the
'employeeId' column.

When I say:
q = orm.query(Time.emp)
print q

A large SQL statement with all the columns in 'Time' appears.  I would
like it to just show the Time.employee_time column.  Is this possible
using only the orm library, or must I use the tables underlying
columnn objects?



On Mar 9, 1:12 pm, "Michael Bayer" <[email protected]> wrote:
> specify the join as an "on" condition:
>
> q.join(Time.account)
> q.join(Time.job)
>
> Bryan wrote:
>
> > I have a table 'Time' that has many-to-1 relationships to tables 'Job'
> > and 'Account'.  There is also a 1-to-many relationship between job and
> > Account.
>
> > Tables
> > ----------------------------------------------
> > Time
> >    --> Account
> >    --> Job
> > Job --> Account
>
> > I am trying to pull back a few rows from Time, Job and Account via the
> > orm library.  I want to try and avoid using the actual sql objects.
>
> > I can't join them simply like below because the reference between Job
> > and Account is making the join ambiguous.  I want to join Time to Job
> > and Time to Account.
>
> > q = orm.query(
> >       func.sum(Time.hours),
> >       Time.day,
> >       Job.number,
> >       Account.code
> >      )
> > q = q.join(Job)
> > q = q.join(Account)
>
> > How can i tell sqlalchemy to join Job and Account to Time, and not to
> > eachother?
>
> > Bryan
>
>
--~--~---------~--~----~------------~-------~--~----~
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