Tutorialsteacher

Follow Us

Articles
  • C#
  • C# OOP
  • ASP.NET Core
  • ASP.NET MVC
  • LINQ
  • Inversion of Control (IoC)
  • Web API
  • JavaScript
  • TypeScript
  • jQuery
  • Angular 11
  • Node.js
  • D3.js
  • Sass
  • Python
  • Go lang
  • HTTPS (SSL)
  • Regex
  • SQL
  • SQL Server
  • PostgreSQL
  • MongoDB
  • SQL - Getting Started
  • What is SQL
  • Create Table
  • ALTER TABLE Statements
  • Rename Columns
  • Modify Column Type
  • Drop Columns
  • Rename Tables
  • Drop Tables
  • Insert Statement
  • Update Statement
  • Delete Statement
  • Truncate Statement
  • Merge Statement
  • Null Value
  • Select Query
  • WHERE Clause
  • GROUP BY Clause
  • HAVING Clause
  • ORDER BY Clause
  • SQL - Inner Join
  • SQL - Left Join
  • SQL - Right Join
  • SQL - Full Join
  • SQL - BETWEEN
  • SQL - IN
  • SQL - LIKE
  • SQL - INTERSECT
  • SQL - MINUS
  • SQL - UNION
  • SQL - UNION ALL
  • SQL - DISTINCT
  • SQL - ANY, SOME
  • SQL - ALL
  • SQL - AVG()
  • SQL - COUNT()
  • SQL - MAX()
  • SQL - MIN()
  • SQL - SUM()
Entity Framework Extensions - Boost EF Core 9
  Bulk Insert
  Bulk Delete
  Bulk Update
  Bulk Merge

SQL - NULL Value

You may not insert data to all the columns of a table in the database. If a column defined as NULL column, that means the value of that column can be empty. You are free to insert or update data anytime you want.

To fetch the NULL values from a table, we can use keywords, NULL or NOT NULL. You can not select NULL data of a table by using any comparison operators (e.g. =, !=, >, < ). The special clause IS NULL or IS NOT NULL is needed to check it.

For the demo purpose, the following Employee table will be used in all examples here.

EmpIdFirstNameLastNameEmailPhoneNoSalary
1'John''King''[email protected]''650.127.1834'33000
2'James''Bond''123.456.4568'
3'Neena''Kochhar''[email protected]'17000
4'Lex''De Haan''[email protected]''123.456.4569'15000

The following example will select employees with PhoneNo as NULL.

SQL Script: IS NULL
SELECT * FROM Employee WHERE PhoneNo IS NULL;

The above query will display the following result.

EmpIdFirstNameLastNameEmailPhoneNoSalary
3'Neena''Kochhar''[email protected]'17000

The following query uses IS NOT NULL to return data whose Email value is not NULL.

SQL Script: IS NOT NULL
SELECT * FROM Employee WHERE Email IS NOT NULL;

The above query will display the following result.

EmpIdFirstNameLastNameEmailPhoneNoSalary
1'John''King''[email protected]''650.127.1834'33000
3'Neena''Kochhar''[email protected]'17000
4'Lex''De Haan''[email protected]''123.456.4569'15000

Update the NULL value using the UPDATE statement, as shown below.

SQL Script: IS NOT NULL
UPDATE Employee SET Salary = NULL
WHERE EmpId = 1;

The above query will display the following result.

EmpIdFirstNameLastNameEmailPhoneNoSalary
1'John''King''[email protected]''650.127.1834'
2'James''Bond''123.456.4568'
3'Neena''Kochhar''[email protected]'17000
4'Lex''De Haan''[email protected]''123.456.4569'15000
TUTORIALSTEACHER.COM

TutorialsTeacher.com is your authoritative source for comprehensive technologies tutorials, tailored to guide you through mastering various web and other technologies through a step-by-step approach.

Our content helps you to learn technologies easily and quickly for learners of all levels. By accessing this platform, you acknowledge that you have reviewed and consented to abide by our Terms of Use and Privacy Policy, designed to safeguard your experience and privacy rights.

[email protected]

ABOUT USTERMS OF USEPRIVACY POLICY
copywrite-symbol

2024 TutorialsTeacher.com. (v 1.2) All Rights Reserved.