RE: [PHP-DB] Question about COUNT(*)

2005-07-07 Thread Erick Wellem
Thanks Rory, This query solves the problem: SELECT client.client_name, IFNULL( COUNT( sales.sale_id ) , 0 ) AS total FROM CLIENT LEFT JOIN sales ON client.client_id = sales.client_id GROUP BY client.client_name ORDER BY total DESC Also thanks to Nandar and Prabhu, but MySQL does not recognize

Re: [PHP-DB] Question about COUNT(*)

2005-07-06 Thread Nandar
try this SELECT client_name, COUNT(sale.client_id) as total FROM client, sale WHERE client.client_id *= sale.client_id GROUP BY client_name ORDER BY total DESC nandar - Original Message - From: [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Wednesday, July 06, 2005 1:11 PM Subject:

Re: [PHP-DB] Question about COUNT(*)

2005-07-06 Thread Rory McKinley
[EMAIL PROTECTED] wrote: Hi, Let's say that I have 2 tables: client and sales --- | client_id | client_name | --- | 1 | John| | 2 | Mark| | 3 | Luke| | 4 | Matthew |