SilverHood
FH is my second home
- Joined
- Dec 23, 2003
- Messages
- 2,300
Here's the story...
I have 2 tables, Room and Resident, related by a one to many relationship (by Room No... one room can belong to many residents)
There are 20 rooms in total - rooms that have an occupant are related to the Resident table. Empty rooms have no relations.
Now, how do I write an SQL query to show me all the rooms that have no occupant. Note, that residents that have left still have a relation from the room, but I can get round that by using a "is null" statement on the date of departure field (ie, so it only shows residents still living here).
I can write a query which shows me occupied rooms numbers. If there was some way to write an SQL statement that compared this to the the list of all rooms, and then only showed rooms without a match, then that would be a posibility too.
Sorry if it's a bit muddled... not sure how to write these questions properly
Any help would be mucho appreciated
I have 2 tables, Room and Resident, related by a one to many relationship (by Room No... one room can belong to many residents)
There are 20 rooms in total - rooms that have an occupant are related to the Resident table. Empty rooms have no relations.
Now, how do I write an SQL query to show me all the rooms that have no occupant. Note, that residents that have left still have a relation from the room, but I can get round that by using a "is null" statement on the date of departure field (ie, so it only shows residents still living here).
I can write a query which shows me occupied rooms numbers. If there was some way to write an SQL statement that compared this to the the list of all rooms, and then only showed rooms without a match, then that would be a posibility too.
Sorry if it's a bit muddled... not sure how to write these questions properly
Any help would be mucho appreciated