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

  • Home
  • SEARCH
  • 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 8712813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:11:17+00:00 2026-06-13T05:11:17+00:00

I have a table with the following possible values for the column field_value. But

  • 0

I have a table with the following possible values for the column field_value.

But when I try to select all values which are not ‘CB’, the query result also ignores all NULL values.

Why does this happen?

mysql> select distinct field_value from TableName;
+--------------+
| field_value  |
+--------------+
| S            |
| NULL         |
| CA           |
| CB           |
+--------------+
4 rows in set (6.32 sec)

mysql> select distinct field_value from TableName where field_value!='CB';
+--------------+
| field_value  |
+--------------+
| S            |
| CA           |
+--------------+
2 rows in set (0.15 sec)

mysql>
  • 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-13T05:11:18+00:00Added an answer on June 13, 2026 at 5:11 am

    That’s because any comparisons with NULL also yield NULL (i.e. not truthy nor falsy).

    The special operators IS NULL and IS NOT NULL are used to make useful comparisons against NULL.

    Your query should therefore be:

    ... WHERE field_value!='CB' OR field_value IS NULL;
    

    See also: Working with NULL values

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

Sidebar

Related Questions

I have a query that looks like the following: SELECT * FROM table WHERE
I have DB2 table having following structure CREATE TABLE DUMMY ( ID CHARACTER(10) NOT
I have recently updated my table schema to include a new column, which has
I have a table (items) which is in the following format: ITEMNO | WEEKNO
I have the following query in SQLite: SELECT * FROM t1 ORDER BY t1.field
Let's assume I have the following table class: class TestTable(tables.Table): id = tables.Column() description
I am fairly new to Indexes. I have table following table [FORUM1] [msg_id] [int]
I have table with following structure and test records: +--------+--------+---------+ | vid | number
I have table with following structure Whenever user click on checkbook and click on
I have table with following structure and records. table t1 +------+-------------+---------------------+ | name |

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.