Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Posts
    14

    Unanswered: 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

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    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).

  3. #3
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    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
        )

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Yes.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Tags for this Thread

Posting Permissions

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