I've fried my brain trying to solve this one. Below is a generic description of my scenario and problem. If it sounds like a made-up problem it's because my real problem would take too long to explain, so I used this to simplify things! Can you tell me how to go about this? Adding tables and/or columns is fair game if it is necessary.
SCENARIO:
I'm using a MySQL dbase to track the paint on every wall of a house with multiple rooms. I employ painters who repaint walls of their choice, with just one rule: they can't use the same paint type on adjacent walls.
The Walls table specifies a RoomID, WallID, WallTypeNum and PaintBrand for each wall.
PaintBrand is a foreign index value that allows a link to the Paints table, which specifies a PaintType for each PaintBrand.
The AdjacentWalls table has between 0 and 5 rows for each WallTypeNum, with each row specifying a corresponding AdjacentWallTypeNum (yes, in a normal room there would always be 2, but my real scenario varies between 0 and 5).
QUESTION:
For a given PaintType, how do I select all WallID's from the Walls table where none of the adjacent WallID's have a PaintBrand with that PaintType?
SCENARIO:
I'm using a MySQL dbase to track the paint on every wall of a house with multiple rooms. I employ painters who repaint walls of their choice, with just one rule: they can't use the same paint type on adjacent walls.
The Walls table specifies a RoomID, WallID, WallTypeNum and PaintBrand for each wall.
PaintBrand is a foreign index value that allows a link to the Paints table, which specifies a PaintType for each PaintBrand.
The AdjacentWalls table has between 0 and 5 rows for each WallTypeNum, with each row specifying a corresponding AdjacentWallTypeNum (yes, in a normal room there would always be 2, but my real scenario varies between 0 and 5).
QUESTION:
For a given PaintType, how do I select all WallID's from the Walls table where none of the adjacent WallID's have a PaintBrand with that PaintType?