Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5929619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:26:44+00:00 2026-05-22T14:26:44+00:00

I have below 4 properties in a Filter class. I am going to parse

  • 0

I have below 4 properties in a Filter class. I am going to parse below 4 properties to a StoredProcedure and get the filtered result.

/// <summary>
/// Gets and sets comma seperated condition ids.
/// Patients must have all these conditions in order to satisfy the filter.
/// </summary>
public string MustHaveAllConditions { get; set; }

/// <summary>
/// Gets and sets comma separated condition ids.
/// Patients must not have all of these conditions in order to satisfy the filter.
/// </summary>
public string MustNotHaveAllConditions { get; set; }

/// <summary>
/// Gets and sets comma separated condition ids.
/// Patients must have at least one of these conditions in order to satisfy the filter.
/// </summary>
public string MustHaveAtLeastOneCondition { get; set; }

/// <summary>
/// Gets and sets comma separated condition ids.
/// Patients must not have at least one of these conditions in order to satisfy the filter.
/// </summary>
public string MustNotHaveAtLeastOneCondition { get; set; }

My Stored procedure will have four parameters like below.
Eg:

@*MustHaveAll*Conditions = “1,2”

@*MustNotHaveAll*Conditions = “3,4”

@*MustHaveAtLeastOne*Condition = “5,6,7,8”

@*MustNotHaveAtLeastOne*Condition = “9, 10”

I am using a UDF that returns a table with Ids column.

My question:

Basically I can use SQL “IN” operator to find the patients who has at least one Condition (ie : @MustHaveAtLeastOneCondition ) and “NOT IN” operator combination to filter @MustNotHaveAnyConditions.

Are there any SQL Operators(or esay ways) to filter MustHaveAllConditions, MustNotHaveAllConditions parameters ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:26:45+00:00Added an answer on May 22, 2026 at 2:26 pm
    -- Patients
    declare @Patient table (PatientID int)
    
    -- Conditions per patient
    declare @PatientCondition table (PatientID int, ConditionID int)
    
    -- Conditions table generated from param string
    declare @Condition table (ConditionID int)
    
    -- Test data
    insert into @Patient
    select 1 union all
    select 2 union all
    select 3
    
    insert into @PatientCondition
    select 1, 1 union all
    select 1, 2 union all
    select 1, 3 union all
    select 2, 1 union all
    select 3, 3
    
    insert into @Condition
    select 1 union all
    select 2
    
    
    -- MustHaveAll
    select *
    from @Patient as P
    where P.PatientID in 
      (
        select PC.PatientID
        from @PatientCondition as PC
          inner join @Condition as C
            on PC.ConditionID = C.ConditionID
        group by PC.PatientID
        having count(PC.ConditionID) = (select count(ConditionID) from @Condition)
      )
    
    --MustNotHaveAll
    select *
    from @Patient as P
    where P.PatientID not in 
      (
        select PC.PatientID
        from @PatientCondition as PC
          inner join @Condition as C
            on PC.ConditionID = C.ConditionID
        group by PC.PatientID
        having count(PC.ConditionID) = (select count(ConditionID) from @Condition)
      )
    
    -- MustHaveAtLeastOne
    select *
    from @Patient as P
    where P.PatientID in
      (
        select PC.PatientID
        from @PatientCondition as PC
          left outer join @Condition as C
            on PC.ConditionID = C.ConditionID
        where C.ConditionID is not null
      )
    
    --MustNotHaveAtLeastOne
    select *
    from @Patient as P
    where P.PatientID not in
      (
        select PC.PatientID
        from @PatientCondition as PC
          left outer join @Condition as C
            on PC.ConditionID = C.ConditionID
        where C.ConditionID is not null
      )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class with a set of properties As given below. class ContactInfo
Let's say I have a class which has three properties as below. public class
If I have a class such as below (only with many more properties), is
I have a class below, i have extracted all the properties to a Interface
I have got below two public properties in my DataContract class. I want to
I have the below public class Person { // Properties public string Name {
I have below code in html. <li class=selected runat=server id=lihome><a href=/ISS/home.aspx title=Home><span>Home</span></a></li> Now I
I have below is the html code for TD which gets appended after matching
I have a profile class: class profile(db.Model): user = db.stringProperty() # Other properties ...
I have the below scenario List<Class> Classes = new List<Class>(); Class c1 = new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.