SQL the SELECT DISTINCT statement

The SELECT DISTINCT statement is used to return a unique different value.

SQL SELECT DISTINCT statement

In the table, a column may contain multiple duplicate values, and sometimes you may want to list only the distinct values.
The DISTINCT keyword is used to return a unique different value.

SQL SELECT DISTINCT syntax

SELECT DISTINCT column_name,column_name
FROM table_name;



In this tutorial, we will use the RUNOOB sample database.
The following is the data selected from the “Websites” table:
+ ---- + -------------- + --------------------------- + - ------ + --------- + | id | name          | url                        | alexa | country | + ---- + -------------- + - -------------------------- + ------- + --------- + | 1 | Google | Https : //www.google.cm/ | 1 | USA | | 2 | Taobao | https : //www.taobao.com/ | 13 | CN | | 3 | Rookie Tutorial | http : //www.runoob.COM / | 4689 | CN | | 4 | Twitter | HTTP : //weibo.com/ | 20 | CN | | 5 | Facebook | HTTPS : //www.facebook.com/ | 3 | USA | + --- - + -------------- + --------------------------- + ----- - + --------- +









SELECT DISTINCT instance

The following SQL statement only from the “Websites” table “country” column to select a unique different value, that is, remove the “country” column repeat value:

Examples

SELECT DISTINCT country FROM Websites ;
Output results:

1 comment

  1. Hi. I see that you don’t update your page too often. I know that writing posts is time consuming and boring.

    But did you know that there is a tool that allows you to create new posts using
    existing content (from article directories or other blogs from your niche)?
    And it does it very well. The new articles are unique and pass the copyscape test.
    Search in google and try: miftolo’s tools

Leave a Reply

Your email address will not be published. Required fields are marked *