
- 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
Fetch a specific column value (name) in MySQL
To fetch a specific column value, use LIKE clause. Let us first create a table −
mysql> create table DemoTable1809 ( Name varchar(20) ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1809 values('John'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1809 values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1809 values('Mike'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1809 values('Johnson'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1809;
This will produce the following output −
+---------+ | Name | +---------+ | John | | David | | Mike | | Johnson | +---------+ 4 rows in set (0.00 sec)
Here is the query to fetch a specific value
mysql> select * from DemoTable1809 where Name LIKE 'Johnson%';
This will produce the following output −
+---------+ | Name | +---------+ | Johnson | +---------+ 1 row in set (0.00 sec)
- Related Articles
- Swap a specific column value in MySQL
- Fetch the maximum value from a MySQL column?
- Fetch specific rows from a MySQL table with duplicate column values (names)?
- Replace only a specific value from a column in MySQL
- MySQL random rows sorted by a specific column name?
- Fetch the size of a specific column values in MySQL and display the sum
- Select a specific value between two column values in MySQL?
- JavaScript fetch a specific value with eval()?
- MySQL insert a value to specific row and column
- Place a specific value for NULL values in a MySQL column
- How to find tables with a specific column name in MySQL?
- How to filter some fields in objects and fetch a specific subject name value in MongoDB?
- Fetch the first letter of a column value and insert it in another column with MySQL
- Two ways to fetch maximum value from a MySQL column with numbers
- MySQL CONCAT a specific column value with the corresponding record

Advertisements