Like Operator In Sql Server

Like operator used in where clause it’s use to search exact word from table.
There are two wildcards in Like operator.

_  - Underscore perform a single character

% - Percent sign Perform for zero, multiple and for one character 

Note:
You can mix underscore and percent in query

Like Operator Example

Example 1

SELECT * FROM Employee WHERE Emp_Name LIKE 'T%';

[The following query returns all data where Emp_name starts with T]

Example 2

SELECT * FROM Employee WHERE Emp_Name LIKE 'a%i';

[The following query selects al data and where Emp_Name starts with A and ends with I]

Example 3

SELECT * FROM Employee WHERE Emp_Name LIKE '%T';

[The following query returns all data with Emp_name where all Employee Name end with T]

Example 4

SELECT * FROM Employee WHERE Emp_Name LIKE '%or%';

[Following query returns all data where (or) will be situated in any Employee Name]

Example 5

SELECT * FROM Employee WHERE Emp_Name LIKE '_b%';

[Following query returns all data where b is situated in second position in Emp_Name]

Comments

Popular posts from this blog

Disable right click, Inspect Element and page source using JavaScript in Html and asp.net