Results 1 to 3 of 3

Thread: Small Query

  1. #1
    Join Date
    Dec 2002
    Location
    Nepal
    Posts
    32

    Unanswered: Small Query

    Hi All,

    i have tow table soldlots and clientinf i need to get the ID from clientinf if the same ID is not exits in soldlots. I tried following query but it is not returning correct result.

    for the example the id_lot have 3 id_client and one is already in soldlots but when i run the following query it is displying whole 3 records, it must display only two and ignore the one which already have duplicate in soldlots.

    select clientinf.id_client as cids from clientinf left join soldlots on clientinf.id_client != clientinf.id_client
    where clientinf.id_lot = 44


    Pls advise me how i can make the correct query.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT clientinf.id_client AS cids 
      FROM clientinf 
    LEFT OUTER
      JOIN soldlots 
        ON soldlots.id_client = clientinf.id_client
     WHERE clientinf.id_lot = 44 
       AND soldlots.id_client IS NULL
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Dec 2002
    Location
    Nepal
    Posts
    32
    Hi,

    Thank You very much it is working good.

    Appreciating for your help.

Posting Permissions

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