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
Hi,
Let's say that I have 2 tables: client and sales
---
| client_id | client_name |
---
| 1 | John|
| 2 | Mark|
| 3 | Luke|
| 4 | Matthew |
---
: [PHP-DB] Question about COUNT(*)
Hi,
Let's say that I have 2 tables: client and sales
---
| client_id | client_name |
---
| 1 | John|
| 2 | Mark|
| 3 | Luke|
| 4 | Matthew
[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 |