Now in SQL Tutorial we will discus Like Keyword, SQL
LIKE keyword is another keyword that is used in the SQL WHERE clause.
Basically, SQL LIKE keyword allows us to do a search based on a pattern
rather than specifying exactly what is desired (as in SQL IN Keyword) or
spell out a range (as in SQL BETWEEN Keyword). The syntax for SQL Like Keyword is as follows:
{PATTERN} often consists of wildcards. Here are some examples of SQL Like
Keyword.
'A_Z': All string that starts with 'A', another character,
and end with 'Z'. For example, 'ABZ' and 'A2Z' would both satisfy the condition, while 'AKKZ' would not because there are two characters between A and Z
as an alternative of one.
'ABC%': All strings that start with 'ABC'. For example, 'ABCD' and
'ABCABC' would both satisfy the condition
'%XYZ': All strings that end with 'XYZ'. e.g. 'WXYZ' and
'ZZXYZ' would both satisfy the condition.
'%TE%': All string that contain the pattern 'TE' anywhere. like,
'Kate' and 'Cute' would both satisfy the condition.
Let's say we have the following table:
Table:
Employees
| FirstName |
LastName |
Email |
DOB |
Phone |
| Austin |
Hennery |
austin.it@gamail.com |
24/11/1978 |
446 102-2222 |
| Creston |
Narvon |
narvon_crest@hotmail.com |
22/04/1976 |
443 325-4545 |
| Kate |
Bladen |
kbladen@usa.net |
01/05/1980 |
326 503-3232 |
| Angela |
Julie |
julieee@yahoo.co.uk |
11/12/1977 |
326 323-8888 |
| Bobbi |
Ferguson |
bobi123@kiwibox.com |
10/02/1970 |
506 252-9875 |
| Cute |
Alfa |
cafa@gmail.com |
19/05/1972 |
506 272-4566 |