MySQL Forums
Forum List  »  Newbie

Re: Joining two tables and counting one
Posted by: Chris Stubben
Date: June 03, 2005 08:52PM

Hi,

You can join two tables and use an aggregate function.


SELECT r.Region_name, COUNT(*) AS numrows
FROM Customers c, Regions r
WHERE c.Region=r.ID
GROUP BY r.Region_name


Also, be sure you have indexes on both columns joined in the WHERE clause.


Chris

Options: ReplyQuote


Subject
Written By
Posted
Re: Joining two tables and counting one
June 03, 2005 08:52PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.