MySQL查询仅从具有多个列的表的特定列中选择所有记录

要从特定列中获取记录,请使用以下语法。只需选择您想要记录的特定列-

select yourColumnName from yourTableName;

让我们首先创建一个表-

mysql> create table DemoTable
(
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   Score int
);

使用插入命令在表中插入一些记录-

mysql> insert into DemoTable(Score) values(89);
mysql> insert into DemoTable(Score) values(99);
mysql> insert into DemoTable(Score) values(78);
mysql> insert into DemoTable(Score) values(75);

使用select语句显示表中的所有记录-

mysql> select *from DemoTable;

这将产生以下输出-

+----+-------+
| Id | Score |
+----+-------+
|  1 |    89 |
|  2 |    99 |
|  3 |    78 |
|  4 |    75 |
+----+-------+
4 rows in set (0.00 sec)

以下是从特定列中选择所有记录的查询-

mysql> select Score from DemoTable;

这将产生以下输出-

+-------+
| Score |
+-------+
|    89 |
|    99 |
|    78 |
|    75 |
+-------+
4 rows in set (0.00 sec)