Home >Database >Mysql Tutorial >How can we get one or more columns as output from a MySQL table?

How can we get one or more columns as output from a MySQL table?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBforward
2023-09-08 23:05:081241browse

我们如何从 MySQL 表中获取一列或多列作为输出?

#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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete