- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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