SQL LIKE

SQL LIKE operator is used to search a table column based on a pattern.

SQL LIKE Statement Syntax

SELECT Columns
FROM TableName
WHERE ColumnName LIKE pattern

The pattern usually has wildcards.

SQL LIKE Example

Table: Employees

EmployeeId FirstName LastName Department Salary
203 Mazojys Fxoj Finance 78000
204 Jozzh Lnanyo Finance 45800
205 Syllauu Dfaafk Finance 57000
206 Gecrrcc Srlkrt Finance 62000
302 Jssme Bdnaa Development 75000
303 Dnnaao Errllov Development 55000
304 Tyoysww Osk Development 49000

Example 1
We want to select employees whose first name start with “J”:

SELECT *
FROM Employees
WHERE FirstName like 'J%'

The result will look like:

EmployeeId FirstName LastName Department Salary
204 Jozzh Lnanyo Finance 45800
302 Jssme Bdnaa Development 75000

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>