How to search a string in MySql Table?

By using equal operator we can search a string inside table data.

Create a Table

mysql> create table UserTable
   -> (
   -> FirstName varchar(100),
   -> LastName varchar(100)
   -> );

 

Insert few records in the above created table

mysql> insert into DemoTable values('RR','Tutors');
Query OK, 1 row affected (0.14 sec)

mysql> insert into DemoTable values('Miche','Tutortech');
Query OK, 1 row affected (0.19 sec)

 

Fetch all records from table by

mysql> select *from UserTable;

Ths will return below data

+-----------+----------+
| FirstName | LastName |
+-----------+----------+
| RR           | Tutors     |
| Miche     | Tutortech|
+-----------+----------+
2 rows in set (0.00 sec)

 

Following is the query to search a MySQL table for a specific string

mysql> select *from DemoTable where LastName='Tutors';

 

Output

+-----------+----------+
| FirstName | LastName |
+-----------+----------+
| RR        | Tutors   |
+-----------+----------+
1 row in set (0.00 sec)