SQL NULL Values

0
161

sqltuts

When SELECT command is used along with WHERE clause in order to fetch data from MySQL table of a given database, but the condition implied doesn’t have any result which means it’s empty.

Like you want to search a person whose age is 21 but when you search through the database there is no person like that so it shall return NULL Value but it doesn’t show.

So To handle such those conditions MySQL provides three unique commands

  • IS NULL: command returns true if the needed column value of a particular table is NULL.
  • IS NOT NULL: command returns true if the needed column value of a particular table is not NULL..
  • <=>:command compares values, which (unlike the = operator) is true even for two NULL values.

To look for columns that are or are not NULL, use IS NULL or IS NOT NULL.

USE OF NULL Values in PHP Script:

You can use if…else or any other condition in order to get a query based on the NULL value.

Example:

 

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.