Friday, 16 August 2013

Oracle SQL MINUS on 3 tables

Oracle SQL MINUS on 3 tables

I need to create an Oracle SQL query possibly using MINUS
Booking(BookID, MotelID, ClientID, Date)
Motel(MotelID, MotelName)
Client(ClientID, ClientName)
I can show the names of clients who have stayed at either motel (I think!!!)
SELECT DISTINCT ClientName
FROM (Client INNER JOIN Booking
ON Client.ClientID = Booking.ClientID)
INNER JOIN Motel
ON Booking.MotelID = Motel.MotelID
WHERE (MotelName = 'MotelOne' OR MotelName='MotelTwo');
But I now need to show the clients who have stayed at MotelOne but NOT
MotelTwo.
Very new to this, and trying to get my head around it so any help will be
gratefully accepted!

No comments:

Post a Comment