

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we fetch one or more columns as output from a MySQL table?
The SELECT command can be used to fetch one or more columns as output from MySQL table. An
example is given below to fetch 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 query above fetches two columns ‘Name’ and ‘subject’ from ‘Student’ table.
mysql> Select Address from Student; +---------+ | Address | +---------+ | Delhi | | Mumbai | | Delhi | | Shimla | +---------+ 4 rows in set (0.00 sec)
The query above fetches only one column ‘Address’ from ‘Student’ table.
- Related Questions & Answers
- How can we fetch a particular row as output from a MySQL table?
- How can we combine the values of two or more columns of MySQL table?
- How can we fetch all the records from a particular MySQL table?
- How can we list all the columns of a MySQL view as we can list the columns of a MySQL table?
- How can we fetch alternate even-numbered records from MySQL table?
- How can we fetch alternate odd numbered records from MySQL table?
- How can we fetch a second highest salary of an employee from a MySQL table?
- How can we add FOREIGN KEY constraints to more than one fields of a MySQL table?
- How to create a data frame with one or more columns as a list in R?
- How can we combine values of two or more columns of MySQL table and get that value in a single column?
- How can we remove a column from MySQL table?
- How can we get more details about columns of an existing table than return by MySQL SHOW COLUMNS statement?
- How can we fetch a MySQL SET column as a list of integer offset?
- How we can get more information about columns of a table than the information we got by DESCRIBE, EXPLAIN and SHOW COLUMNS MySQL statements?
- Delete more than one rows from a table using id in MySQL?
Advertisements