I have two tables that I am accessing in one MYSQL query. From one table I want individual records. From the second table, I want a count of records. The query I am making returns only one row, when I need it to return several. Here's my code:
SELECT c.name, c.city, count(z.zones)
FROM controllers AS c
INNER JOIN zones AS z ON c.con_id = z.con_id
WHERE c.user_id = 1;
This returns:
Backyard unit, San Francisco, 21
When I need it to return:
Backyard unit, San Francisco, 6
Side yard controller, Marin, 8
Upper backyard, San Mateo, 7
I've tried many many different strategies to access what I need, and I feel like I'm getting close. It seems like I'm missing something important here.
By the way, I am using PHP to process these results.Thank you in advance for the help. I love this forum. I find so many answers here. But this time I keep coming up short.
Lori