In sql statement, like all usage

 

In sql structured query language, like the statement it has a vital role.

statement is syntax like: SELECT  *  from  table  where  field name like the corresponding value (substring), it is primarily for the character field, its role is to retrieve a character column contains the corresponding field substring.

A:% any string of zero or more characters:

1, like'Mc% 'searches for all strings that begin with the letters Mc (e.g. McBadden).

2, like '% inger' searches for all strings that ends with inger (e.g. Ringer, Stringer).

3, like '% en%' searches for all strings that contain the letters en anywhere (e.g., Bennet, Green, McBadden).

B: _ (underscore) Any single character:

like'_heryl 'will search for all six-letter names ending with the letter heryl (such as Cheryl, Sheryl).

C: [] specified range ([AF]), or any single character set ([abcdef]) of: 

1, like '[CK] ars [eo] n' will search for the following string: Carsen, Karsen, Carson and Karson (such as Carson).

2, like '[MZ] inger' searches for all names ending string inger, any single letter M to Z from the beginning (e.g., Ringer).

D: [^] does not belong to the specified range ([AF]) or set ([abcdef]) any single character:

like'M [^ c]% 'The search starts with the letter M, and the second letter of all names not c (e.g. MacFeather).

E: * It is different from the DOS command wildcard for multiple characters:

发布了153 篇原创文章 · 获赞 6 · 访问量 2352

Guess you like

Origin blog.csdn.net/yangshengwei230612/article/details/103779008