All request records exist within the Request table. They can then be filtered because some also belong in an additional table, either Booking or Declined. Rooms and vwRoomRequest don’t affect this query.
I’m trying to return records which have been ‘declined’, they therefore exist in both the Requests table AND the Declined table and the primary key of these 2 tables will be the same.
In the real query, I’m using group by Request.RequestID because this query returns 2488 results when there are in fact only 17 rows in the Request table!
The main problem (other than the above), is that this query is returning the same result as if the this line of the query were not there :
AND Request.RequestID<>BookingID AND Request.RequestID<>Declined.RequestID.
SELECT *
FROM Request , Rooms, Booking, Declined, vwRoomRequest
WHERE Request.RoomID = Rooms.RoomID
AND Rooms.RoomID = vwRoomRequest.RoomID
AND Request.RequestID<>BookingID
AND Request.RequestID<>Declined.RequestID
Any ideas?
If you’re trying to return all requests that have been declined, why not just return all rows from the
Declinedtable andLEFT JOINin whatever other tables you need? Something like this: