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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:02:45+00:00 2026-05-12T22:02:45+00:00

I’ve seen this on a lot of fields on a DB from a project

  • 0

I’ve seen this on a lot of fields on a DB from a project I’ve been working on, where a column will be defined not null, but will have an empty string as the default. what’s the point of doing this? If you will allow an empty string, why not just allow a field to be null?

  • 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-12T22:02:46+00:00Added an answer on May 12, 2026 at 10:02 pm

    NULLs have special behavior: comparing anything with a NULL gives you back a NULL, which is something else than false or 0. It means “unknown”.

    For example, take this table:

     user_id | gender
    ------------------
     1       | NULL
     2       | 'M'
     3       | 'F'
     4       | 'F'
    

    SELECT * FROM mytable WHERE gender = 'M' will return 1 row, as expected

    SELECT * FROM mytable WHERE gender != 'M' will return 2 rows, NOT 3 rows.

    SELECT * FROM mytable WHERE gender != 'M' OR gender IS NULL will return the expected 3 rows.


    Edit: For some applications, using 0 (or, God forbid, another “magic number”) instead of NULL is not even advisable (units or exact values are not relevant in this example):

     Date       | Temperature 
    --------------------------
     2010-01-01 | 10          
     2010-01-02 | 4
     2010-01-03 | 0
     2010-01-04 | -22
     2010-01-05 | -45
     2010-01-06 | NULL
     2010-01-07 | -34
    

    Here, the NULL on Jan 6th means “value unknown” – maybe because the temperature was so low that the thermometer probe stopped responding. However, it’s a completely different meaning than Jan 3rd, when the temperature was 0, that is, 0 degrees.

    Also, as @Bill Karwin mentions, NULLs behave specially in aggregate functions (COUNT,SUM,AVG etc.): calculating AVG(Temperature) on the above data would give you -14.5, as the NULL row is ignored.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.