In the SQL structured query language, the LIKE statement has a vital role. The grammatical format of the LIKE statement is: select * from the name of the WHERE field name LIKE correspondence value (substring), it is primarily for the characteristic field, and its role is to retrieve the corresponding subquerry in a character field column. Suppose there is a table Table1 in a database, there are two fields in Table1, namely Name and SEX are all characteristic data. Now we have to query the records starting with the word "Zhang" in the name field, the statement is as follows: select * from table1 where name like "Zhang *" If you want to query the record of "Zhang", the statement is as follows: SELECT * from Table1 WHERE Name Like "*" This uses a wildcard "*", it can be said that the LIKE statement is not open. Below we will introduce the wildcards.
Match type mode examples and representative values Description Multiple characters * c * c represents a wildcard such as CC, CBC, CBC, Cabdfec, etc., represents multiple characters. Multiple character%% C% represents AGDCAGD, etc. In many programs, it is mainly queried to contain substrings. Special characters [*] a [*] A represents a * a replace * single character? B? B represents BRB, BFB is equivalent to DOS command? The wildcard, represents a single character single number # k # k represents K1K, K8K, K0K is approximately the same, and the difference is that only a single number can only represent a single number. Character range - [a-z] represents any one of the 26 letters of A to Z
Continued
Exclude [! Characters] [! AZ] represents 9, 0,%, *, etc. It only represents a single character number excludes [! Number] [! 0-9] represents A, B, C, D, etc., the same type of characters [range " Type] Character CC [AD] # Represents CCF #, etc. can be used in combination with several other methods.