Search code examples
javascriptmysqlrecord

Not show duplicated record


I have a simply problem: some record of one column of my db are:

  • house
  • house
  • palace
  • house
  • bar
  • palace
  • house

I want to show a list without duplicate record like:

  • house
  • palace
  • bar

I use JS to search into my mysql db and if i write this code that show me the first list:

    if (Search.EOF) { Response.Write("") }
    else while (!Search.EOF) {

          Response.Write(Search("columnname"))

        Search.Movenext();
    }

How can i jump the duplicated record?


Solution

  • Use DISTINCT STATEMENT.

     SELECT DISTINCT column_name,column_name FROM table_name;