If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Small Query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-30-08, 09:45
abdul_zu abdul_zu is offline
Registered User
 
Join Date: Dec 2002
Location: Nepal
Posts: 32
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.
Reply With Quote
  #2 (permalink)  
Old 08-30-08, 10:02
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-30-08, 10:09
abdul_zu abdul_zu is offline
Registered User
 
Join Date: Dec 2002
Location: Nepal
Posts: 32
Hi,

Thank You very much it is working good.

Appreciating for your help.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On