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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:56:01+00:00 2026-05-13T16:56:01+00:00

I had am maintaining an query that is as follows: select field_1, field_2 from

  • 0

I had am maintaining an query that is as follows:

select field_1, field_2
from source_table
minus
select field_1, field_2
from source_table
where status_code in (3, 600);

When I looked at this query, I immediately thought, “That’s lame. Why not just use a ‘NOT IN’ and remove the MINUS business. So I re-wrote it as so:

select field_1, field_2
from source_table
where status_code not in (3, 600);

Just to double-check my sanity, I got counts of each query. To my surprise, the first query returned 789,089 records, and the second query returned 1,518,450 records!

I’ve looked at this from several angles but can’t figure out how these two queries are different. Can anyone explain what is going on, or why I am an idiot this morning?

  • 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-13T16:56:01+00:00Added an answer on May 13, 2026 at 4:56 pm

    These queries are indeed different. field_1 and field2 do not equate to status_code 3 and 600. field_1 could be ‘A’ and field_2 could be ‘B’, so you would be eliminating records from the first SELECT that look like A, B. The original is probably the best way of achieving the correct result.

    Edit: To give you a better idea of what’s going on, you could get the same result, in a similar fashion to how you thought to write the query, by doing a subquery:

    select distinct field_1, field_2
    from source_table
    where (field_1, field_2) not in (
        select field_1, field_2
        from source_table
        where status_code in (3, 600)
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've had a look at this question but I'm still having trouble maintaining the
I noticed that a site I'm maintaining had a little layout bug in FF/IE8/Chrome
What are some strategies that people have had success with for maintaining a change
I'm maintaining some C code that was written by the person who had my
I have a PHP website I'm maintaining and I've confirmed that this worked at
I'm maintaining code for a mathematical algorithm that came from a book, with references
Had to download Command Line Tools from Apple to get make to work, but
Had received a module from CCAVENUE and it was working fine with Magento 1.6.2...
Had a page that was working fine. Only change I made was to add
Had a good search here but can't see anything that gets my mind in

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.