On Thu, Jul 21, 2005 at 10:09:07PM -0700, Benjamin Smith wrote:
> select classroom.title, 
>       count(students.id) AS students, 
>       count(seats.id) AS seats
> from classrooms, students, seats
> where classrooms.id=students.classrooms_id
> and classrooms.id=seats.id 
> 
> Except that it counts 0s for seats/students. 
> 
> Why can't I recall/find how to do this particular join? 

Sounds like you're looking for an outer join.

http://www.postgresql.org/docs/8.0/static/tutorial-join.html
http://www.postgresql.org/docs/8.0/static/queries-table-expressions.html#QUERIES-FROM

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Reply via email to