Selecting all records containing a Null or Empty value in 1 field

M

Mota

Hello;
I have a Table named MainTBL,having a String field named DOP.
I need a Sql statement that can select all records having DOP=Null or
DOP=Empty.How to write this statement?
Thank you so much.
 
A

Allen Browne

A Text field with nothing in it has the value Null. If the text field's
Allow Zero Length property is set to Yes, the field could also be a zero
length string. A field cannot have the value Empty - that applies only to
Variants in VBA code.

To test for both possible cases:
SELECT * FROM MainTBL WHERE DOP Is Null OR DOP = '';

You almost never need fields in Access/JET to contain zero length strings,
so you can simplify life by setting the Allow Zero Length property to No for
all your text fields.
 
M

Mota

Thank you for your help.

Allen Browne said:
A Text field with nothing in it has the value Null. If the text field's
Allow Zero Length property is set to Yes, the field could also be a zero
length string. A field cannot have the value Empty - that applies only to
Variants in VBA code.

To test for both possible cases:
SELECT * FROM MainTBL WHERE DOP Is Null OR DOP = '';

You almost never need fields in Access/JET to contain zero length strings,
so you can simplify life by setting the Allow Zero Length property to No for
all your text fields.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top