I am trying to make a simple reservation system.
I have two tables as room_types, and rooms. In rooms, I have a boolean field, showing that if that room is available or not. I want to list room types, where there exist at least one room available for that type. I know I need to use join and count, but I couldn’t put together the whole query. Any help is appreciated.
My schema (trimmed unnecessary fields):
room_types [id, name(varchar), size(int), price(float) ...]
rooms [no (int), type (int) (foreign key room_types(id)), available (bool), ...]
The concept is in there, but I can’t write the query exactly since I do not know your schema. I do hope though that you learn what you need from this and apply it to your own schema.
With counting (including room types where there may to be available rooms).