如何从 MySQL 表中提取一个或多个列作为输出?
可以使用 SELECT 命令从 MySQL 表中提取一个或多个列作为输出。下面提供了
一个示例,用于提取一个或多个列
mysql> Select * from Student; +------+---------+---------+-----------+ | Id | Name | Address | Subject | +------+---------+---------+-----------+ | 1 | Gaurav | Delhi | Computers | | 2 | Aarav | Mumbai | History | | 15 | Harshit | Delhi | Commerce | | 17 | Raman | Shimla | Computers | +------+---------+---------+-----------+ 4 rows in set (0.01 sec) mysql> Select Name,Subject from Student; +---------+-----------+ | Name | Subject | +---------+-----------+ | Gaurav | Computers | | Aarav | History | | Harshit | Commerce | | Raman | Computers | +---------+-----------+ 4 rows in set (0.00 sec)
以上查询从“Student”表中提取了两列“姓名”和“科目”。
mysql> Select Address from Student; +---------+ | Address | +---------+ | Delhi | | Mumbai | | Delhi | | Shimla | +---------+ 4 rows in set (0.00 sec)
以上查询只从“Student”表中提取了一列“地址”。
广告