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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:49:40+00:00 2026-05-16T03:49:40+00:00

Ok here goes: I have a table with id ( can be duplicate but

  • 0

Ok here goes:

I have a table with id ( can be duplicate but not NULL ) and value ( can be duplicate and NULL )

id      value
-----   -----
1       red
1       red
1       (null)
2       blue
2       blue
3       (null)

So how do I return the id’s and value’s of all the records that have a value, but if a null value is also found don’t include it in the result set.

So the return would be

id      value
-----   -----
2       blue

as id 1 and 3 have a value of (null) in one or more of the results

  • 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-16T03:49:41+00:00Added an answer on May 16, 2026 at 3:49 am

    It’s a typical “select where not exists”-type query with many ways to write the answer, for example:

    Using a LEFT JOIN / WHERE … IS NULL:

    SELECT DISTINCT T1.id, T1.value
    FROM your_table T1
    LEFT JOIN your_table T2
    ON T1.id = T2.id AND T2.value IS NULL
    WHERE T2.id IS NULL
    

    Using NOT IN:

    SELECT DISTINCT id, value
    FROM your_table
    WHERE id NOT IN
    (
        SELECT DISTINCT id
        FROM your_table
        WHERE value IS NULL
    )
    

    Using NOT EXISTS:

    SELECT DISTINCT id, value
    FROM your_table
    WHERE NOT EXISTS
    (
        SELECT NULL
        FROM your_table T1
        WHERE your_table.id = T1.id AND T1.value IS NULL
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Weird to describe but here goes. I have a table with several rows. One
I'm not exactly sure how to phrase this, but here goes... We have a
This may have been asked already, but I can't find it, so here goes.
Not sure if this is possible, but here goes. I have a MongoDB (using
I'm guessing this isn't possible, but here goes. I have two tables, and I'm
A slightly archaic question I'm afraid but here goes: I have a program which
This is a very basic question...quite embarassing, but here goes: I have a Stopwatch
OK, I don't think the title says it right... but here goes: I have
I have a feeling my problem is a bit strange, but here goes... I
I've a feeling this might not be possible, but here goes... I've got a

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.