Results 1 to 4 of 4

Thread: what's better? NULL or empty text?

Hybrid View

  1. #1
    Join Date
    Mar 2010

    what's better? NULL or empty text?

    what's better, for a cell to contain a value of NULL or empty text like '' ..?
    is there an advantange one way or another?

    thank you,

  2. #2
    Join Date
    Aug 2004
    I suspect using NULL might make searches a bit more efficient in some cases, but that's just speculation on my part. The main reason I'd consider using NULL is for the ability to filter on it with IS NULL and IS NOT NULL. It just seems a bit cleaner to me to do...
    SELECT * FROM foo WHERE bar IS NOT NULL ORDER BY something
    SELECT * FROM foo WHERE bar != '' ORDER BY something
    (Even though the 2nd version takes fewer keystrokes, for some reason the first seems clearer and more semantically correct to me.)

    Also, depending on what DBMS you are using, some have nifty shortcuts for sorting all nulls to the top or bottom regardless of ASC or DESC sort order, which can sometimes be useful.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Nov 2012
    Very interesting, I never really gives this a major thought. I simply uses "" (empty string).

    Most related functions I used are coded in PHP. So I never uses NULL.

    It might come in handy if you do use the functions inside SQL though.

  4. #4
    Join Date
    Mar 2010
    belated thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center