
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to get a specific column record from SELECT query in MySQL?
Let us first create a table −
mysql> create table DemoTable1837 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(20) ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1837(StudentName) values('Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1837(StudentName) values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1837(StudentName) values('Bob'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1837(StudentName) values('Mike'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1837;
This will produce the following output −
+-----------+-------------+ | StudentId | StudentName | +-----------+-------------+ | 1 | Chris | | 2 | David | | 3 | Bob | | 4 | Mike | +-----------+-------------+ 4 rows in set (0.00 sec)
Here is the query to get a specific column records:
mysql> select StudentName from DemoTable1837;
This will produce the following output −
+-------------+ | StudentName | +-------------+ | Chris | | David | | Bob | | Mike | +-------------+ 4 rows in set (0.00 sec)
- Related Articles
- How to select a specific record from MySQL if date is in VARCHAR format?
- MySQL query to select records beginning from a specific id
- How to select record except the lower value record against a specific value in MySQL?
- MySQL query to get a specific row from rows
- MongoDB query to get record beginning with specific element from an array?
- How to select a random record from a MySQL database?
- MySQL query to place a specific record on the top
- MySQL query to select a record with two exact values?
- MySQL query to select all the records only from a specific column of a table with multiple columns
- Get multiple count in a single MySQL query for specific column values
- MySQL query to get result from multiple select statements?
- How to add a column from a select query but the value from the new column will be the row count of the MySQL select query?
- MongoDB query to find a specific city record from a collection
- MySQL query to select average from distinct column of table?
- Get the new record key ID from MySQL insert query?

Advertisements