List:General Discussion« Previous MessageNext Message »
From:Benjamin Scherrey Date:April 4 1999 7:37am
Subject:Re: count(*) involving several tables?
View as plain text  
select name, count( table1_id ) from table1 left join table2 on table2.table1_id
= group by name;
Should give you the results you're looking for.


        Ben Scherrey

Bjoern Frantzen wrote:

> 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, count(table2.table1_id)
>    FROM table1, table2
>    WHERE = 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.

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