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 > Sybase > validate resultset has all the options given within WHERE IN clause..??

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-20-10, 00:54
vikram3.r@tcs.com vikram3.r@tcs.com is offline
Registered User
 
Join Date: Aug 2009
Posts: 14
validate resultset has all the options given within WHERE IN clause..??

select * from Table where column1 IN (value1, value2, value3)

The above query retrieves the records , for which column1's value is either value1 or value2 or value3. It doesn't matter if any of the 3 options are missing.


Is there a way to validate, the resultset of the query has got value1, value2, value3 records atleast once..??
__________________
Vikram RM
Reply With Quote
  #2 (permalink)  
Old 04-20-10, 09:18
MCrowley MCrowley is online now
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
You could run a separate query to see how many of each (value1, value2, value3) are in the table (and therefore would be returned by the query above).
Reply With Quote
  #3 (permalink)  
Old 04-20-10, 10:30
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Maybe something like this
Not tested
Code:
select * from table a where column1 IN (value1, value2, value3)
  and exists
    (select 1 from table b 
     where a.xxx=b.xxx
       and column1 IN (value1, value2, value3)
     group by xxx
     having count(distinct column1)=3
    )
Reply With Quote
  #4 (permalink)  
Old 04-20-10, 13:29
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
Yes.

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
Reply

Tags
resultset, select, validate, where in

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