Results 1 to 2 of 2

Thread: SQL Query

  1. #1
    Join Date
    Apr 2002

    Unanswered: SQL Query

    I need a sql query but dont know how to write it. I have two table one called Staff and other Contracted_Staff. Now who ever is assigned a contract the StaffId is entered into Contracted_Staff Table, so that way i know which staff is assigned to what contract.

    Now on the new contract section i want to select all the Staff from the table Staff who has not been assigned to any contract (available staff in other words). I want to exclude all the Staff who are in Contracted_Staff table. Now i do i go about writing that query.

    Thanks for your help.


  2. #2
    Join Date
    Jan 2003
    Rockville, MD
    Use a "Left Join" like this:
    SELECT Staff.*
    FROM Staff LEFT JOIN Contracted_Staff ON Staff.StaffId = Contracted_Staff.StaffId
    WHERE (((Contracted_Staff.StaffId) Is Null));

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts