like is another directive that will be used in the where clause. Basically, like allows us to find the information we need based on a nested pattern. In contrast, when we use in, we fully know the conditions we need, and when we use between , we make a list of them. The syntax for like is as follows:
Select "Field name"
From "Table name"
WHERE "field name" like {nested};
{nested} often includes wild cards (wildcard). Here are a few examples:
' A_z ': All start with ' A ', another word of any value, and a string ending with ' Z '. Both ' ABZ ' and ' a2z ' conform to this pattern, and ' akkz ' does not conform (because there are two characters between A and Z, not a single word).
' abc% ': all the strings beginning with ' ABC '. For example, ' ABCD ' and ' abcabc ' conform to this set of formula.
'%XYZ ': all strings ending with ' XYZ '. For example, ' wxyz ' and ' zzxyz ' all fit this set.
'%an% ': All strings containing ' an ' this set. For example, ' LOS ANGELES ' and ' SAN FRANCISCO ' match this set.We will use the last example above on our store_information form:
store_information Form
Store_name |
Sales |
Txn_date |
LOS ANGELES |
1500 |
05-jan-1999 |
SAN DIEGO |
250 |
07-jan-1999 |
SAN FRANCISCO |
300 |
08-jan-1999 |
BOSTON |
700 |
08-jan-1999 |
We enter,
SELECT *
From Store_information
WHERE store_name like '%an% ';Results:
Store_name |
Sales |
Txn_date |
LOS ANGELES |
1500 |
jan-05-1999 |
SAN FRANCISCO |
300 |
jan-08-1999 |
SAN DIEGO |
250 |
jan-07-1999 |
The results of Linux testing are as follows:
Reprint please specify: Xiao Liu
A concise tutorial of SQL statements for Linux---like