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)
登錄后復(fù)制
上面的查詢從“學(xué)生”表中獲取兩列“姓名”和“主題”。
mysql> Select Address from Student; +---------+ | Address | +---------+ | Delhi | | Mumbai | | Delhi | | Shimla | +---------+ 4 rows in set (0.00 sec)
登錄后復(fù)制
上面的查詢僅從“學(xué)生”表中獲取一列“地址”。
以上就是我們?nèi)绾螐?MySQL 表中獲取一列或多列作為輸出?的詳細內(nèi)容,更多請關(guān)注www.92cms.cn其它相關(guān)文章!