2
Answers

Selecting between tables

Mohamed Shehab

Mohamed Shehab

12y
1.7k
1
Dear guys:
               i'm developing a booking system for a clinic, so my problem is that i want to display available doctor shift which are not already reserved, the patient check the availability of a certain doctor in specific date and shift.
i have 2 tables Booking (ID, DocID, shift_id, Date)and Shift table (ID, name, DocID)
my SQL selecting query which r not working is:

SELECT        Shift.ID, Shift.name, Shift.DocID
FROM            Shift INNER JOIN
                         Booking ON Shift.ID = Booking.shift_id
WHERE        (Shift.DocID = @DoctorID) AND (Booking.DocID <> @DoctorID) AND (Booking.shift_id <> @ShiftID) AND (Booking.Date <> @VisitDate)

so please any ideas???

Answers (2)