1WHERE CustomerName LIKE 'a%'
2--Finds any values that start with "a"
3WHERE CustomerName LIKE '%a'
4--Finds any values that end with "a"
5WHERE CustomerName LIKE '%or%'
6--Finds any values that have "or" in any position
7WHERE CustomerName LIKE '_r%'
8--Finds any values that have "r" in the second position
9WHERE CustomerName LIKE 'a__%'
10--Finds any values that start with "a" and are at least 3 characters in length
11WHERE ContactName LIKE 'a%o'
12--Finds any values that start with "a" and ends with "o"
1#SELECT * FROM table_name WHERE columnName LIKE pattern;
2SELECT * FROM wilayah_2020 WHERE kode LIKE "82%"
3
4kode nama
5---------------------------------
682.72.08 Tidore Timur
782.72.08.1001 Mafututu
882.72.08.1002 Tosa
982.72.08.1003 Dowora
1082.72.08.1004 Kalaodi
1182.72.08.1005 Cobodoe
1282.72.08.1006 Doyado
1382.72.08.1007 Jiko Cobo
14
15# 'a%' Finds any values that start with "a"
16# '%a' Finds any values that end with "a"
17# '%or%' Finds any values that have "or" in any position
18# '_r%' Finds any values that have "r" in the second position
19# 'a_%' Finds any values that start with "a" and are at least 2 characters in length
20# 'a__%' Finds any values that start with "a" and are at least 3 characters in length
21# 'a%o' Finds any values that start with "a" and ends with "o"
1The LIKE operator is a logical operator that tests whether a string contains a specified pattern or not. Here is the syntax of the LIKE operator:
2
3expression LIKE pattern ESCAPE escape_character
4
5This example uses the LIKE operator to find employees whose first names start with a:
6
7SELECT
8 employeeNumber,
9 lastName,
10 firstName
11FROM
12 employees
13WHERE
14 firstName LIKE 'a%';
15
16 This example uses the LIKE operator to find employees whose last names end with on e.g., Patterson, Thompson:
17
18SELECT
19 employeeNumber,
20 lastName,
21 firstName
22FROM
23 employees
24WHERE
25 lastName LIKE '%on';
26
27
28 For example, to find all employees whose last names contain on , you use the following query with the pattern %on%
29
30SELECT
31 employeeNumber,
32 lastName,
33 firstName
34FROM
35 employees
36WHERE
37 lastname LIKE '%on%';
1-- example
2SELECT Id, ProductName, UnitPrice, Package
3 FROM Product
4 WHERE ProductName LIKE 'Cha_' OR ProductName LIKE 'Chan_'
1eturns true if the operand value matches a pattern.
2Example: Returns true if the user’s first_name ends with ‘son’.
3SELECT * FROM users
4WHERE first_name LIKE '%son';
5
1WHERE CustomerName LIKE 'a%'
2--Finds any values that start with "a"
3WHERE CustomerName LIKE '%a'
4--Finds any values that end with "a"
5WHERE CustomerName LIKE '%or%'
6--Finds any values that have "or" in any position
7WHERE CustomerName LIKE '_r%'
8--Finds any values that have "r" in the second position
9WHERE CustomerName LIKE 'a__%'
10--Finds any values that start with "a" and are at least 3 characters in length
11WHERE ContactName LIKE 'a%o'
12--Finds any values that start with "a" and ends with "o"
13
14(Like) Operator for partial searches using wildcard '%' and '_'
15For Example:
16Select * From Employees
17Where last_name LIKE '_a%';