Mohamed Shehab

Mohamed Shehab

  • NA
  • 4
  • 1.9k

Selecting between tables

Nov 29 2011 10:14 AM
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)