I have this
SELECT power_distributors.power_distributor_id, title, manufacturer, model, created_date, enabled, number_of_outlets, number_of_devices FROM power_distributors LEFT JOIN (SELECT power_distributor_id, COUNT(device_id) AS number_of_devices FROM devices) AS tpr ON tpr.power_distributor_id = power_distributors.power_distributor_id WHERE type = 1 LIMIT 0, 10
When I look in the devices table
There are a total of four devices, but only 2 with a power_distributor_id of 1
I thought the JOIN would only count the two, not all the devices. I cant put a WHERE clause in the joined statement, so how do I make it only count 2?