Changing Null Displays

If members of your audience are not database-literate, they might find NULL confusing and decide it means zero. You can prevent trouble by using a function to substitute a value for NULL. On Adaptive Server Anywhere, this function is COALESCE (with two arguments) or ISNULL.

COALESCE ( expr, value-to-substitute-if-null)

The type column in the titles table allows NULL. Here's how the data looks

SQL
select title_id, type
from titles
title_id type
======== ============
PC8888   popular_comp
BU1032   business
PS7777   psychology
PS3333   psychology
BU1111   business
MC2222   mod_cook
TC7777   trad_cook
TC4203   trad_cook
PC1035   popular_comp
BU2075   business
PS2091   psychology
PS2106   psychology
MC3021   mod_cook
TC3218   trad_cook
MC3026   (NULL) ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.