Results 1 to 6 of 6

Thread: SQL Not Equal Query [Resolved By memnoch and apps_tech]

  1. #1

    Thread Starter
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    SQL Not Equal Query [Resolved By memnoch and apps_tech]

    Hi,
    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.

    Danial

    PS: Sorry for posting this in General VB, but i really need the answer urgently.
    Last edited by Danial; Jun 10th, 2003 at 05:04 PM.
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    something like

    Code:
    SELECT * FROM Staff WHERE staffId NOT IN SELECT staffId FROM contracted_staff
    it will select all staff members who are not contracted.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3
    Hyperactive Member
    Join Date
    May 2003
    Posts
    401

    Re: SQL Not Equal Query

    Try this:

    Select * from Staff where staffId Not in ( select distinct staffid from contracted_staff)

    Hope this works..do let me know if not...

    Enjoy!!!
    apps_tech

  4. #4

    Thread Starter
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: Re: SQL Not Equal Query

    Originally posted by apps_tech
    Try this:

    Select * from Staff where staffId Not in ( select distinct staffid from contracted_staff)

    Hope this works..do let me know if not...

    Enjoy!!!
    apps_tech
    That worked like a charm !!

    Thanks Millions to both memnoch and apps_tech.

    Danial
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  5. #5
    Hyperactive Member
    Join Date
    May 2003
    Posts
    401

    Re: SQL Not Equal Query

    Try this:

    Select * from Staff where staffId Not in ( select distinct staffid from contracted_staff)

    Hope this works..do let me know if not...

    Enjoy!!!
    apps_tech

  6. #6
    Hyperactive Member
    Join Date
    May 2003
    Posts
    401

    Re: Re: SQL Not Equal Query

    Originally posted by apps_tech
    Try this:

    Select * from Staff where staffId Not in ( select distinct staffid from contracted_staff)

    Hope this works..do let me know if not...

    Enjoy!!!
    apps_tech
    Sorry, some trouble in my system my answer got posted again...

    apps_tech

Posting Permissions

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



Click Here to Expand Forum to Full Width