 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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
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)
Advertisements
 