Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
Joe
Forum Regular
Posts: 939 Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow
Post
by Joe » Sun Oct 03, 2004 7:32 pm
Is it possible to use COUNT(*) when using an OUTER JOIN. My query looks like:
Code: Select all
SELECT members.ID, comments.comment FROM members, comments
WHERE members.ID = comments.ID;
I wish for the members ID to be shown but at the same time I wish to count the number of rows which hold the same ID as members.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Oct 03, 2004 10:31 pm
generally all joins can use a grouping function, however you will need a group by.
bling
Forum Commoner
Posts: 25 Joined: Mon Jul 12, 2004 12:44 pm
Post
by bling » Mon Oct 04, 2004 9:14 am
Yeah, just group by all the fields you select. As long as they are all "unique" you shouldn't have a problem, however this group by might slow down your query a good deal.
If your rows aren't unique then you will also have to group by some unique identifier.