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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:08:03+00:00 2026-05-25T00:08:03+00:00

Suppose there is a table like this: f1 f2 ———- 1 3 4 8

  • 0

Suppose there is a table like this:

f1      f2
----------
1       3
4       8
6       4
NULL    1

The following query works as expected :

SELECT f2
  FROM Table_1 a
 WHERE NOT EXISTS (SELECT *
                     FROM Table_1 
                    WHERE a.f2 = f1)

…and result set is:

f2
---
3
8

…but similar query with IN returns nothing:

SELECT f2
  FROM Table_1 a
 WHERE f2 NOT IN (SELECT b.f1 
                    FROM Table_1 b)

What’s the problem ?

  • 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-25T00:08:04+00:00Added an answer on May 25, 2026 at 12:08 am

    It is because of the null value in f1. Try this instead.

    SELECT      f2
    FROM         Table_1 a
    WHERE f2 NOT IN (select b.f1 
                     from Table_1 b
                     where b.f1 is not null)
    

    Here is a great explanation as to why it is so. NOT IN clause and NULL values

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

Sidebar

Related Questions

suppose I have a sql like this: select * from tba if table tba
Suppose there was a SQL table like this: Label Name | Last name |
Suppose I have a command like this: select name, age, haircolor from people where
Suppose I have a MySQL table called MyTable, that looks like this: +----+------+-------+ |
Suppose I have a simple MySQL table that looks like this: CREATE TABLE `my_table`
Suppose I have a table like this: ID Result ------------- 1 , 'pass' 2
Suppose I have an entity like this: @Entity @Table(name = ITEMS) public class Item
Suppose I have simple table like this: ID (PRIMARY) time (INT) stage (TINYINT) other
Suppose I have a table like this: +-----------+ | | | | | |
Suppose there're 2 tables with data like below: -- Table #Detail TelNO ---------- 001xxxxx

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.