I have 2 tables, the first table is is Apartments and it has ApartmentID and the other table is Rooms and has RoomsID, I'm trying to get the total amount of rooms per apartment but my issue is that, the total isn't a value of itself, the room table has a row for each room custom values, so if I run something like this SELECT * FROM Rooms
I will get all data like this
ApartmentID = 1 , RoomID = 1 , WallPaint = Red etc...
ApartmentID = 1 , RoomID = 2 , WallPaint = blue etc...
As you can see, I can have several rooms that belongs to ApartmentID 1
What I want to achieve is, a query that returns for me the amount of Rooms for All Apartment ID, Like I'm trying to get such a response from server
ApartmentID 1 has 4 Rooms
ApartmentID 2 has 3 Rooms
This is just an example but ofcourse the response will be in JSON. I though about doing INNER JOIN query to get the data, but that only got me data I need for ApartmentID 1, how to I loop through all ApartmentID and for each ApartmentID I get the total Rooms in it keeping in mind that I need to count all rows for rooms and return the total as a value