You are currently offline, waiting for your internet to reconnect

How to use SQL Select to Locate NULL Values

This article was previously published under Q128072
This article has been archived. It is offered "as is" and will no longer be updated.
When using Visual FoxPro version 3.0, you may want to use the SQL SELECTcommand to locate records in which a particular field contains null values.This article explains how to do it.
If a table contains null values (represented as .NULL.) the followingSELECT statement will always return zero records even when cFld1 containsnull values:
   SELECT * FROM mytable WHERE cFld1 = .NULL.				
Null should be used when a value is missing, irrelevant, or unknown. Whenany conditional expression encounters a null value, a .NULL. will bereturned. A value of true (.T.) or false (.F.) cannot be returned if partof the expression is unknown or null. The expression in the above example,cFld1 = .NULL., will never evaluate to True, instead it will evaluate to.NULL. and as a result no records will be returned.

To locate .NULL. values in cfld1, use the new IS NULL clause of the SQLSELECT command. The IS NULL clause is new to Visual FoxPro version 3.0. Itprovides a mechanism for comparing fields with .NULL. values and returningtrue or false. For example, consider this SELECT command:
   SELECT * FROM mytable WHERE cfld1 IS NULL				
In this example, whenever cfld1 is .NULL., the IS NULL clause will causethe SELECT command to return a .T. and the desired records.

Article ID: 128072 - Last Review: 12/04/2015 11:10:33 - Revision: 1.1

Microsoft Visual FoxPro 3.0 Standard Edition

  • kbnosurvey kbarchive KB128072