From: Matthew Wilson <matt@tp...> - 2008-11-20 19:34:51
I have a table of employees and a table of shifts and I want to write a
single query like this:
select emp.name, shifts.start_time
from employees emp, shifts
where emp.department_id = 99
and emp.id = shifts.employee_id
I can't figure out how to do this with SQLObject.
When I do this:
x = Shift.select(AND(
I get the right shifts, but when I try to display information from the
employee table, then for each row, SQLObject does a single query.
In other words, when I do:
[(sh.employee.name, sh.start_time) for sh in x]
Then for every shift in the query results, I see SQLObject go back to
the database again to get that employee's name.
Is there a better way?