>I've got two tables > >A. Branches >B. Employees > >I need to loop through the "Branches" table, and count the number of >matching employees from the employees table..
There are probably better SQL people on this list who can correct me, but I believe this should work: SELECT branch_name, count(employees) AS numEmployees FROM branches, employees WHERE branches.branch_id = employees.branch_id GROUP BY branch_name I'm just coming up with that on the fly, but that's the basic idea, so it probably needs some tweaking. Scott -------------------------------- Scott Brady http://www.scottbrady.net/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm