List:General Discussion« Previous MessageNext Message »
From:Bjoern Frantzen Date:April 3 1999 1:55am
Subject:count(*) involving several tables?
View as plain text  
Given the following two tables;

table1:
id
name

table2:
table1_id

How can i do a select which returns all names from table1 and a count of how
many relations there is in table2?

When I do
   SELECT table1.name, count(table2.table1_id) 
   FROM table1, table2
   WHERE table1.id = table2.table1_id
it works except I don't get the names of those without a relation in table2.
I would like to have them listed as well with 0 relations.

It's just takes too long to do the count for each row as I do now.

-- 
             Bjørn Frantzen

     
Thread
count(*) involving several tables?Bjoern Frantzen3 Apr
  • Re: count(*) involving several tables?Benjamin Scherrey4 Apr
    • Re: Re: count(*) involving several tables?Bjoern Frantzen4 Apr