Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: SQL Unmatched records Question

Re: SQL Unmatched records Question

From: Phil Cook <pacookSPAM_IRIS_at_blueyonder.co.uk>
Date: Sat, 12 May 2001 23:55:11 GMT
Message-ID: <z3kL6.706$wV1.100320@news1.cableinet.net>

Charcoal <who_at_cares.com> wrote in message news:_mcL6.264$V5.1159_at_news1.rivrw1.nsw.optushome.com.au...
> Hi again,
>
> I have two tables in an Oracle database and I want to display all the
> records in one table which are NOT in the other table. Let me explain
 using
> the schema below:
>
> Seats(SeatID) which ranges from 1 to 10. {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
> SoldSeats(FlightID, SeatID) which defines which seats have been sold for a
> particular flight.
>
> So for example, if seats 1,2,3 have been sold for FlightID 100 then I
 would
> want it to return
>
> 100 4
> 100 5
> 100 6
> 100 7
> 100 8
> 100 9
> 100 10
>
> But if a seat has been sold in another Flight, then it shouldnt affect
> Flight 100's results. So what is the SQL Query to do something like this?
>

I would say

SELECT Seats.SeatID, SoldSeats.FlightID
FROM Seats, SoldSeats
WHERE SoldSeats.FlightID = 100

MINUS SELECT SeatID, FlightID
FROM SoldSeats
WHERE FlightID = 100 Received on Sat May 12 2001 - 18:55:11 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US