How to search a specified pattern in a column in SQL?

It is used to search a specified pattern in a column. The two wildcards operator used in conjunction with the LIKE operator.

  • % – The percent sign is used to represent one or more characters.
  • _ – The underscore sign is used to represent only one Character.

Syntax:

SELECT column1, column2….
FROM table_name
WHERE column1 LIKE %XXX;
‘OR’
SELECT column1, column2….
FROM table_name
WHERE column1 LIKE %XXX%;
‘OR’
 
SELECT column1, column2….
FROM table_name
WHERE column1 LIKE _XXX;
‘OR’
SELECT column1, column2….
FROM table_name
WHERE column1 LIKE XX_X;
‘OR’
SELECT column1, column2….
FROM table_name
WHERE column1 LIKE %XX_X;
Example:
SELECT Name, Roll_no
FROM Student_details
WHERE Name LIKE %tesh;

 

Name Roll No.
Jitesh 6

Become a Database Architect

Course Schedule

Name Date
SQL Training 2022-12-03 2022-12-04
(Sat-Sun) Weekend batch
View Details
SQL Training 2022-12-10 2022-12-11
(Sat-Sun) Weekend batch
View Details
SQL Training 2022-12-17 2022-12-18
(Sat-Sun) Weekend batch
View Details

Leave a Reply

Your email address will not be published. Required fields are marked *