DISTINCT where
时间: 2023-10-17 18:28:40 浏览: 106
DISTINCT is a keyword in SQL that is used in conjunction with the SELECT statement to retrieve unique values from a column or a combination of columns. It ensures that the result set does not contain any duplicate values. The DISTINCT keyword can be used in various scenarios, such as:
1. Retrieving distinct values from a single column:
```
SELECT DISTINCT column_name
FROM table_name;
```
2. Retrieving distinct combinations of values from multiple columns:
```
SELECT DISTINCT column1, column2
FROM table_name;
```
The DISTINCT keyword operates on the entire row, so it considers all the selected columns when determining uniqueness. It is commonly used when you want to filter out duplicate entries and focus only on unique values in your queries.
阅读全文