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

The Archive Base Latest Questions

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

What approach should I follow to construct my SQL query if I need to

  • 0

What approach should I follow to construct my SQL query if I need to select a data exepct some other data?

For example, my

I want so select all the data from the data-base EXCEPT this result-set:

SELECT *
FROM table1
WHERE table1.MarketTYpe = 'EmergingMarkets'
AND IsBigOne = 1
AND MarketVolume = 'MIDDLE'
AND SomeClass = 'ThirdClass'

Should I use

  • NOT IN (the aboe result set)
  • Or shoudl I get INVERSE of the conditions like != inseat of = etc.
  • Or ?

Can you advice?

  • 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-26T20:26:23+00:00Added an answer on May 26, 2026 at 8:26 pm

    Use the EXCEPT construct?

    SELECT *
    FROM table1
    EXCEPT
    SELECT *
    FROM table1
    WHERE table1.MarketTYpe = 'EmergingMarkets'
    AND IsBigOne = 1
    AND MarketVolume = 'MIDDLE'
    AND SomeClass = 'ThirdClass'
    

    Note that EXCEPT and NOT EXISTS give the same query plan using “left anti semi joins”.

    NOT IN (subquery with above) may not give correct results if there are NULL values in the sub-query, hence I wouldn’t use

    I would avoid negation in the WHERE clause because it isn’t readable straight away
    As the comments show on Michael’s answer…

    For more on “all rows except some rows”, see these:

    • Combining datasets with EXCEPT versus checking on IS NULL in a LEFT JOIN
    • To take out those dept who has no employees assigned to it
    • SQL NOT IN possibly performance issues
    • (DBA.SE) https://dba.stackexchange.com/questions/4009/the-use-of-not-logic-in-relation-to-indexes/4010#4010
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am starting with c++ and need to know, what should be the approach
I'm kind of curious how I should approach a problem with iPhones and communication
I have a question about best practices regarding how one should approach storing complex
How should I best approach drawing a scatter plot diagram in Cocoa?
Can Agile/XP go together with layered approach? Should Agile/XP go together with layered approach?
Which approach is better to use if I need a member (sp or func)
I have several classes that need to load some properties files, and I was
I'm trying to follow code-to-interface on a project. Should I be creating an interface
Test case schema and data follow as: create table tmp ( vals varchar(8), mask
When you approach a class you want to write, how do you plan its

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.