Re: [SQLObject] Ordering by a column of a foreign key...
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Simon C. <hod...@gm...> - 2008-06-18 22:33:14
|
On Wed, Jun 18, 2008 at 9:58 PM, Sam's Lists <sam...@gm...> wrote: > I have a select like this: > > progs_running = list(ProgRun.select(AND(ProgRun.q.progressID == '3', > ProgRun.q.pingTime > > cutoff), > > orderBy=ProgRun.q.theCompany)) > > where theCompany is a foreign key. > > What I'd really like to do though is order it by the company name, which is > stored in the table that the foreign key theCompany connects to. You can try something like: ProgRun.select(AND( ProgRun.q.progressID == '3', ProgRun.q.pingTime > cutoff, ProgRun.q.the_company_id == Company.q.id ), orderBy=Company.q.name) I haven't tested this and I don't know the name of the class that theCompany attribute links to so it may need some tweaking. |