I have two tables Route and Booking
CREATE TABLE Route (
RouteID numeric(4),
RouteIMG blob,
RDetails varchar2(40),
CONSTRAINT Route_pk PRIMARY KEY (RouteID));
And
CREATE TABLE Booking (
BookingID numeric(4),
BookingType varchar2(1),
StartTime date,
EndTime date,
Date date,
History varchar2(25),
RouteID numeric(4),
ExaminerID numeric(4),
InstructorID numeric(4),
StudentID numeric(4),
CONSTRAINT Booking_pk PRIMARY KEY (BookingID),
CONSTRAINT Route_fk FOREIGN KEY (RouteID) REFERENCES Route,
CONSTRAINT Student_fk FOREIGN KEY (StudentID) REFERENCES Student);
I want to compare Booking.RouteId with Route.RouteId and return the Id which isn’t in the Booking table.
For example,
Route Table contains the Route Id’s
0001
0002
0003
and in the Bookings table the routes booked are
0001
0002
How can I complete this comparison and return the value
0003
You can use
left joinand then you should check the booking_id is null.or you can use: