sql示例
SQL Select Distinct命令有什么作用? 区别是什么意思? (What does the SQL Select Distinct command do? What does Distinct Mean?)
This keyword allows us to get lists of unique values in a column. This guide will demonstrate that.
此关键字使我们能够获取列中唯一值的列表。 本指南将证明这一点。
完整显示学生表中的数据 (Full display of the data in the student table)
USE fcc_sql_guides_database;
SELECT studentID, FullName, sat_score, programOfStudy, rcd_Created, rcd_Updated FROM student;
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
| studentID | FullName | sat_score | programOfStudy | rcd_Created | rcd_Updated |
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
| 1 | Monique Davis | 400 | Literature | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
| 2 | Teri Gutierrez | 800 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
| 3 | Spencer Pautier | 1000 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
| 4 | Louis Ramsey | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
| 5 | Alvin Greene | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
| 6 | Sophie Freeman | 1200 | Programming | 2017-08-16 15:34:50 | 2017-08-16 15:34:50 |
| 7 | Edgar Frank "Ted" Codd | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
| 8 | Donald D. Chamberlin | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
| 9 | Raymond F. Boyce | 2400 | Computer Science | 2017-08-16 15:35:33 | 2017-08-16 15:35:33 |
+-----------+------------------------+-----------+------------------+---------------------+---------------------+
9 rows in set (0.00 sec)
获取研究领域清单 (Get list of fields of study)
SELECT DISTINCT programOfStudy FROM student;
+------------------+
| programOfStudy |
+------------------+
| Literature |
| Programming |
| Computer Science |
+------------------+
3 rows in set (0.00 sec)
As with all of these SQL things there is MUCH MORE to them than what’s in this introductory guide.
与所有这些SQL事物一样,它们比本入门指南中的内容要多得多。
I hope this at least gives you enough to get started.
我希望这至少能给您足够的入门。
Please see the manual for your database manager and have fun trying different options yourself.
请参阅数据库管理员的手册,并尝试自己尝试其他选项,这很有趣。
翻译自: https://www.freecodecamp.org/news/sql-distinct-explained-with-examples/
sql示例