May 2020
Beginner
564 pages
14h 9m
English
DISTINCT is a keyword that, when added to a SELECT statement, will return only distinct (or different) values within a column. Sometimes, you may want to see what values are contained in a column, and getting the distinct values will help you see this. For example, if you want to see the distinct player IDs in the appearances table, you should execute the following query:
USE lahmansbaseballdb;SELECT DISTINCT playerid FROM appearances;
The following screenshot shows the results of the preceding query. Note that the rows returned are far fewer than in the previous section. This list only shows the distinct player IDs, and there are 19,429 of them:
You can also select multiple columns in DISTINCT
Read now
Unlock full access