Using Distinct when populating a Drop-Down Box

Discussion in 'ASP General' started by MasterChief, Oct 31, 2005.

  1. MasterChief

    MasterChief Guest

    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"
    MasterChief, Oct 31, 2005
    #1
    1. Advertising

  2. MasterChief wrote:
    > 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.
    Dave Anderson, Oct 31, 2005
    #2
    1. Advertising

  3. MasterChief wrote:
    > 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
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Oct 31, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SirPoonga
    Replies:
    2
    Views:
    741
    Ben Strackany
    Jan 7, 2005
  2. =?Utf-8?B?YXNhZA==?=

    Populating Drop down box value

    =?Utf-8?B?YXNhZA==?=, Aug 2, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    453
    Stephen
    Aug 2, 2005
  3. weiwei
    Replies:
    0
    Views:
    1,001
    weiwei
    Jan 5, 2007
  4. Hicham Mouline
    Replies:
    1
    Views:
    382
    Kai-Uwe Bux
    Apr 11, 2010
  5. Matt Davidson
    Replies:
    3
    Views:
    99
    kaeli
    Jul 23, 2004
Loading...

Share This Page