Re: SQL query for NULL field entries
Posted in 1992
Topics: SQL Development & Query Writing
caulds%deh1@redstone-emh2.army.mil (Charles Aulds /AMSMI-RA-EH-RM/876-0889) writes: : What I want to do is select records where a specific field contains : no entry. The following line does NOT work, but will illustrate what : I need to do: : : select jocpbc.* from jocpbc where pbcj=" "; : : The following line also fails to return the desired rows: : : select jocpbc.* from jocpbc where pbcj=""; : : The column 'pbcj' is type character, but I need the query to work as : well for date columns. ..this illustrates an SQL "pet peeve" of mine: When fields are allowed to hold nulls, a simple two-state compare becomes a three-state compare. You need to now look for a specific value, the "default" non-value (usually a zero for numerics or a space for alphas), and, finally, the infamous NULL value. Informix (and other RDBMSs) allow the DB designer to specify no-nulls, but people forget, or the classes don't stress this point, etc... Chris ("Just Say No to Nulls.") Edler ------------------------------------------------------------------------------- Christopher Edler Information Technology cedler@boi.hp.com Hewlett-Packard Company Boise, Idaho USA