The best SQL SELECT DISTINCT statement Tutorial In 2024, In this tutorial you can learn SQL SELECT DISTINCT statement,SELECT DISTINCT examples,Examples,
SELECT DISTINCT statement is used to return only difference values.
In the table, a column might contain multiple duplicate values, sometimes you may want to just list the different (distinct) values.
DISTINCT keyword is used to return only difference values.
In this tutorial, we will use w3big sample database.
The following is a selected "Websites" table data:
+----+--------------+---------------------------+-------+---------+ | id | name | url | alexa | country | +----+--------------+---------------------------+-------+---------+ | 1 | Google | https://www.google.cm/ | 1 | USA | | 2 | 淘宝 | https://www.taobao.com/ | 13 | CN | | 3 | 本教程 | http://www.w3write.com/ | 4689 | CN | | 4 | 微博 | http://weibo.com/ | 20 | CN | | 5 | Facebook | https://www.facebook.com/ | 3 | USA | +----+--------------+---------------------------+-------+---------+
The following SQL statement only "country" column "Websites" list select the only different values, that is, to remove the "country" duplicate column values:
Output: