Using Distinct when populating a Drop-Down Box

M

MasterChief

I have a Drop Down box that is being populated using the SQL Distinct
command. How do I get it so it doesn't show Null values?

Here is my SQL statement

sSQL = "SELECT DISTINCT Title FROM Everyone ORDER BY Title ASC"
 
D

Dave Anderson

MasterChief said:
I have a Drop Down box that is being populated using the SQL Distinct
command. How do I get it so it doesn't show Null values?

Here is my SQL statement

sSQL = "SELECT DISTINCT Title FROM Everyone ORDER BY Title ASC"

SELECT DISTINCT Title
FROM Everyone
WHERE Title IS NOT NULL
ORDER BY Title ASC



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
B

Bob Barrows [MVP]

MasterChief said:
I have a Drop Down box that is being populated using the SQL Distinct
command. How do I get it so it doesn't show Null values?

Here is my SQL statement

sSQL = "SELECT DISTINCT Title FROM Everyone ORDER BY Title ASC"

It depends. If you simply want to exclude Null values, then use a WHERE
clause:

sSQL = "SELECT DISTINCT Title FROM Everyone " & _
"WHERE Not Title IS NULL ORDER BY Title ASC"

If you want the Null value replaced by some text, then the answer depends on
the type and version of database you are using (please don't forget to
include that information when asking database-related questions - it is
almost always relevant)

Bob Barrows
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top