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 7853407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:40:49+00:00 2026-06-02T19:40:49+00:00

If I type: SELECT name FROM table WHERE name NOT IN (‘Test1′,’Test2′,’Test3’); I can

  • 0

If I type:

SELECT name FROM table WHERE name NOT IN ('Test1','Test2','Test3');

I can get the entries from the table that are not in the list. I want to do the opposite: Get the values from the list that are not in the table. For example, if table has a column named name that has the values ‘Test1’ and ‘Test3’ I want to compare that to (‘Test1′,’Test2′,’Test3’) and return Test2. Or as another example, if the table is empty, then return everything in the list: Test1, Test2, and Test3.

Is there a way to do this WITHOUT creating a new table with all of the values in the list?

  • 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-06-02T19:40:51+00:00Added an answer on June 2, 2026 at 7:40 pm

    Depending on how many values you have, you could do a few unions.

    See: http://www.sqlfiddle.com/#!5/0e42f/1

    select * from (
      select 'Test 1' thename union
      select 'Test 2' union 
      select 'Test 3'
    )
    where thename not in (select name from foo)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this SELECT name FROM sqlite_master WHERE type = table AND name
My development log fills up with SELECT name FROM sqlite_master WHERE type = 'table'
IF EXISTS (SELECT name FROM sysobjects WHERE name = 'myTrigger' AND type = 'TR')
and get meaningful results. Currently I am running these three queries: SELECT t.type,t.id,s.title FROM
I'm trying to SELECT entries of a certain type, name, EXCLUDING entries with the
INSERT INTO [Tasks] ([LoginName] ,[Type] ,[Filter] ,[Dictionary] ,[Description]) Select N'Anonymous',4,'SomeTable.targetcode in (select Code from
I want to SELECT a formatted date string from a datetime type in SQL
I have a query like this: select data_name into v_name from data_table where data_table.type
I have this query: select distinct id,name from table1 For a given ID, the
Using: select name, id from TEST where id :2 AND name :1 order by

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.