If im joining two tables, both of which im using a count(*) on... how would i do t his? I cant just do Table1.count(*) , Table2.count(*).. it just doesnt seem to work... any idea how this would be done?
Thanks!
Using Count(*) with an inner join...
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Jcart wrote:What do you mean it just doesn't work? Using COUNT(*) is perfectly acceptable using inner joins.
So your saying that the following should work?
Code: Select all
SELECT Table1.ID, Table2.ID, Table1.count(*), Table2.count(*) From Table1 Inner Join Table2 on Table1.ID = Table2.ID- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
SELECT `Table1`.`ID`, `Table2`.`ID`, COUNT(*) as `count` FROM `Table1` INNER JOIN `Table2` ON `Table1`.`ID` = `Table2`.`ID`