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)
上面的查询从“学生”表中获取两列“名称”和“主题”。
mysql> Select Address from Student; +---------+ | Address | +---------+ | Delhi | | Mumbai | | Delhi | | Shimla | +---------+ 4 rows in set (0.00 sec)
上面的查询仅从“学生”表中获取“地址”一列。