Query Help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Query Help

Post by Joe »

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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

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 »

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.
Post Reply