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
Release: 2023-09-08 23:05:08
forward
1258 people have browsed it

我们如何从 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)
Copy after login

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)
Copy after login

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 of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template