- Introduction To SQL
- SQL Syntax
- SQL SELECT Statement
- SQL SELECT DISTINCT Statement
- SQL WHERE Clause
- SQL AND, OR And NOT Operators
- SQL ORDER BY Keyword
- SQL INSERT INTO Statement
- SQL NULL Values
- SQL UPDATE Statement
- SQL DELETE Statement
- SQL TOP, LIMIT, FETCH FIRST Or ROWNUM Clause
- SQL MIN() And MAX() Functions
- SQL COUNT(), AVG() And SUM() Functions
- SQL LIKE Operator
- SQL Wildcards
- SQL IN Operator
- SQL BETWEEN Operator
- SQL Aliases
- SQL Joins
- SQL INNER JOIN Keyword
- SQL LEFT JOIN Keyword
- SQL RIGHT JOIN Keyword
- SQL FULL OUTER JOIN Keyword
- SQL Self Join
- SQL UNION Operator
- SQL GROUP BY Statement
- SQL HAVING Clause
- SQL EXISTS Operator
- SQL ANY And ALL Operators
- SQL SELECT INTO Statement
- SQL INSERT INTO SELECT Statement
- SQL CASE Statement
- SQL NULL Functions
- SQL Stored Procedures For SQL Server
- SQL Comments
- SQL Operators
- SQL CREATE DATABASE Statement
- SQL DROP DATABASE Statement
- SQL BACKUP DATABASE For SQL Server
- SQL CREATE TABLE Statement
- SQL DROP TABLE Statement
- SQL ALTER TABLE Statement
- SQL Constraints
- SQL NOT NULL Constraint
- SQL UNIQUE Constraint
- SQL PRIMARY KEY Constraint
- SQL FOREIGN KEY Constraint
- ALTER TABLE Orders DROP CONSTRAINT FK_PersonOrder;
- SQL DEFAULT Constraint
- SQL CREATE INDEX Statement
- SQL AUTO INCREMENT Field
- SQL Working With Dates
- SQL Views
- SQL Injection
- SQL Hosting
- SQL Data Types For MySQL, SQL Server, And MS Access
SQL NULL Functions
SQL IFNULL(), ISNULL(), COALESCE(), And NVL() Functions
Look at the following "Products" table:
P_Id | ProductName | UnitPrice | UnitsInStock | UnitsOnOrder |
---|---|---|---|---|
1 | Jarlsberg | 10.45 | 16 | 15 |
2 | Mascarpone | 32.56 | 23 | |
3 | Gorgonzola | 15.67 | 9 | 20 |
Suppose that the "UnitsOnOrder" column is optional, and may contain NULL values.
Look at the following SELECT statement:
FROM Products;
In the example above, if any of the "UnitsOnOrder" values are NULL, the result will be NULL.
Practice Excercise Practice now
Solutions
MySQL
The MySQL IFNULL()
function lets you return an alternative value if an expression is NULL:
FROM Products;
or we can use the
COALESCE()
function, like this:
FROM Products;
SQL Server
The SQL Server ISNULL()
function lets you return an alternative value when an expression is NULL:
FROM Products;
MS Access
The MS Access IsNull()
function returns TRUE (-1) if the expression is a null value, otherwise FALSE (0):
FROM Products;
Oracle
The Oracle NVL()
function achieves the same result:
FROM Products;
Practice Excercise Practice now
Products
Partner
Copyright © RVR Innovations LLP 2024 | All rights reserved - Mytat.co is the venture of RVR Innovations LLP