Home >Database >Mysql Tutorial >How can we get one or more columns as output from a MySQL table?
#The SELECT command can be used to get one or more columns as output from a MySQL table. An
example is given below to get one or more columns
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)
The above query gets two columns "Name" and "Subject" from the "Students" table.
mysql> Select Address from Student; +---------+ | Address | +---------+ | Delhi | | Mumbai | | Delhi | | Shimla | +---------+ 4 rows in set (0.00 sec)
The above query only gets one column "Address" from the "Students" table.
The above is the detailed content of How can we get one or more columns as output from a MySQL table?. For more information, please follow other related articles on the PHP Chinese website!