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

  • SEARCH
  • Home
  • 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 895201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:31:19+00:00 2026-05-15T14:31:19+00:00

Lets consider I have a table ‘Tab’ which has a column ‘Col’ The table

  • 0

Lets consider I have a table ‘Tab’ which has a column ‘Col’

The table ‘Tab’ has this data –

Col
1
2
3
4
5

If I have a set of values (2,3,6,7). I can query the values that are present in the table and the list by suing the query

Select Col from Tab where col IN (2,3,6,7)

But, if I want to return the values in the list that are not present in the table i.e. only (6,7) in this case. What query should I use?

  • 1 1 Answer
  • 1 View
  • 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-15T14:31:20+00:00Added an answer on May 15, 2026 at 2:31 pm

    The problem I believe is that your trying to find values from you in statement. What you need to do is turn your in statement into a table and then you can determine which values are different.

    create table #temp
    (
    value int
    )
    
    insert into #temp values 1
    insert into #temp values 2
    insert into #temp values 3
    insert into #temp values 4
    
    select
     id
    from
     #temp
    where
     not exists (select 1 from Tab where Col = id)
    

    A better alternative would be to create a table-valued function to turn your comma-delimited string into a table. I don’t have any code handy, but it should be easy to find on Google. In that case you would only need to use the syntax below.

    select
     id
    from
     dbo.SplitStringToTable('2,3,6,7')
    where
     not exists (select 1 from Tab where Col = id)
    

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this scenario. I have an object, lets call it.... Foo. Foo raises a
For my question lets consider the following sample table data: ProductID    ProductName    Price   Category 1                Apple                 5.00       Fruits
I have a question about HTTPService and the data it returns. Well lets consider
I have the following problem: Let's consider we have #define SET callMe #define COLUMN(x)
I have an issue with an SQL Query. Lets take this example data itemID
This question requires some hypothetical background. Let's consider an employee table that has columns
Lets consider I have the following function: SomeType createSomeType(); which can throw depending on
Let's say I have a table that has a varchar field. If I do
I've a doubt. Lets consider that we have a div of width 200px. If
Lets consider I have a string called string s = jpeg, jpg, gif, png;

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.