I am new at this, but if listings and agents are both tables I do not see a reference in the select statement:
select name, count(*) as cnt from agents as p1, listings as p2 where p1.name = p2.agent; Or something like that............ Chuck http://68.43.100.7:81/aa8vs ========================================== "Patriotism is the willingness to kill and be killed for trivial reasons." - Bertran Russell -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, December 20, 2002 2:14 PM To: [EMAIL PROTECTED] Subject: Count and Selects I'm trying to get a count of records by combining a search from 2 seperate tables. I have both listings and agents as tables. What I need to do is get a agent, ad count for all the agents listed in agents even if they don't have any ads in listings. Here's the query: select name, count(*) as cnt from agents where name = listings.agent; I keep getting an error saying unknown table listings but it is definately there. TIA, Ed --------------------------------------------------------------------- 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 --------------------------------------------------------------------- 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