Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Usage » Queries: Selecting Data from a Table » The WHERE clause: specifying rows

Character strings and quotation marks Next Page

Unknown Values: NULL

A NULL in a column means that the user or application has made no entry in that column. A data value for the column is unknown or not available.

NULL does not mean the same as zero (numerical values) or blank (character values). Rather, NULL values allow you to distinguish between a deliberate entry of zero for numeric columns or blank for character columns and a non-entry, which is NULL for both numeric and character columns.

Entering NULL

NULL can be entered in a column where NULL values are permitted, as specified in the create table statement, in two ways:

For example, the DepartmentHeadID column of the Departments table allows nulls. You can enter two rows for departments with no manager as follows:

INSERT INTO Departments (DepartmentID, DepartmentName)
   VALUES (201, 'Eastern Sales')
INSERT INTO Departments
   VALUES (202, 'Western Sales', null);
When NULLs are retrieved

When NULLS are retrieved, displays of query results in Interactive SQL show (null) in the appropriate position:

FROM Departments;
DepartmentID DepartmentName DepartmentHeadID
100 R & D 501
200 Sales 904
300 Finance 1293
400 Marketing 1576
500 Shipping 703
201 Eastern Sales (null)
202 Western Sales (null)

Testing a column for NULL
Properties of NULL