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 > Data Access, Manipulation & Batch Languages > ANSI SQL > Not In Clause

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-15-03, 12:34
prashantdalal prashantdalal is offline
Registered User
 
Join Date: Dec 2003
Posts: 2
Lightbulb Not In Clause

Hi,

My Following select st. is running from last one day. I think the problem is NOT IN clause.
Please suggest the alternative select clause.



SELECT resreq.proj, resreq.ver, substr(resreq.act, -5, 5) act, resreq.rn, null,
null, resreq.rl, resreq.dr, resreq.ra
FROM resreq
WHERE resreq.ver IN ('0', '99')
AND NOT (resreq.proj, resreq.ver, substr(resreq.act, -5, 5), resreq.rn)
IN (SELECT actres.proj, actres.ver, substr(actres.act, -5, 5) act,
actres.rn
FROM actres, resreq
WHERE actres.proj = resreq.proj
AND actres.ver = resreq.ver
AND substr(actres.act, -5, 5) = substr(resreq.act, -5, 5)
AND actres.rn = resreq.rn
AND actres.ver IN ('0', '99'))




Best Regards,
Prashant Dalal
prashantdalal@hotmail.com
http://prashantdalal.port5.com
Reply With Quote
  #2 (permalink)  
Old 12-16-03, 07:33
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: Not In Clause

Try NOT EXISTS, with the subquery corellated (joined) to the main query.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 12-16-03, 08:33
edwinjames edwinjames is offline
Registered User
 
Join Date: Dec 2003
Posts: 74
DOES THIS WORK?

SELECT
resreq.proj,
resreq.ver,
substr(resreq.act, -5, 5) act,
resreq.rn,
null,
null,
resreq.rl,
resreq.dr,
resreq.ra
FROM
resreq
WHERE
resreq.ver IN ('0', '99')
AND (resreq.proj, resreq.ver, substr(resreq.act, -5, 5), resreq.rn)
NOT IN (SELECT
actres.proj,
actres.ver,
substr(actres.act, -5, 5) act,
actres.rn
FROM
actres,
resreq
WHERE
actres.proj = resreq.proj
AND actres.ver = resreq.ver
AND substr(actres.act, -5, 5) = substr(resreq.act, -5, 5)
AND actres.rn = resreq.rn
AND actres.ver IN ('0', '99'))
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