I'm coming up empty on this one and it should be quite simple. Maybe because it's Friday??
I have 2 tables, Dept and Employee. I want to count the # of employees in each dept and store it in the corresponding Dept row. To do the tally it is simply creating a temporary table: drop table if exists empl_count; create table empl_count select dept_id, count(*) num from employee group by dept_id; create index dept_ndx on empl_count (dept_id); Ok, now that I have the empl_count table, now what? I can write a PHP program to go through the dept table and lookup each num in empl_count for each dept_id, but there has to be an easier way to do this. Is there any way to quickly update the dept table with the results of the tally? Can I eliminate the empl_count table entirely and update the dept table directly? The empl_count table could have 100k rows so I don't want to do any looping in PHP if at all possible. TIA Brent sql.query _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php