|
The SQL LIKE keyword enable us to query the database using the text pattern. We often use the Wildcard in conjunction with the LIKE keyword to search for data.
SYNTAX:
SELECT "column_name"
FROM "table_name"
WHERE "column_name" LIKE {PATTERN}
Table: Student
| StudentID |
LastName |
FirstName |
DOB |
CourseFees |
CourseName |
| 1 |
John |
Astone |
07/15/1976 |
1000.00 |
Accountant |
| 2 |
Bob |
Eastwood |
02/13/1935 |
1500.00 |
Economic |
| 3 |
Jane |
Hollywood |
03/23/1939 |
2000.00 |
IT |
| 4 |
Bob |
Eastwood |
03/19/1980 |
3000.00 |
Economic |
Example #1
In this example we will select all the student records where the student FirstName begins with East.
SELECT * FROM Student
WHERE FirstName LIKE 'East%'
RESULT:
| StudentID |
LastName |
FirstName |
DOB |
CourseFees |
CourseName |
| 2 |
Bob |
Eastwood |
02/13/1935 |
1500.00 |
Economic |
| 4 |
Bob |
Eastwood |
03/19/1980 |
3000.00 |
Economic |
|