How to exclude duplicate records from a select list?

Discussion in 'Programming' started by unitedlocalbands, Jul 28, 2007.

  1. #1
    I use coldfusion to return the "city" column from a table in the database.
    I want these cities to show up in a "select" tag. What i dont want though is for the same city to show up more than one time.

    Like in the case where there is more than one record with their city being
    San Fransico.

    Right now the SQL statement will show every record. I want it to reconize that there is a duplicate and only display it one time.

    heres an example:
    http://www.unitedlocalbands.com/example.cfm
     
    unitedlocalbands, Jul 28, 2007 IP
  2. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #2
    All you have to do is add DISTINCT to your sql statment:

    SELECT DISTINCT "COLUMN_NAMES"
    FROM "TABLE_NAME"
     
    unitedlocalbands, Jul 28, 2007 IP