Fuzzy query (all for string operations)
Fuzzy query is a bit similar to regular expressions, but it is not as powerful as regular expressions.
Wildcard characters: _,%, [], ^
_ Represents any single string.
select * from Student_Info where Name like '张_'
In this way, find the name of Zhang in the Name column of the Student_Info table, two words; it will not find out the name of Zhang.
Another way is
select * from Student_Info where Name like '张%' and len(Name)=2
How to find Zhang XX, three words
select * from Student_Info where Name like '张__'
% Matches any number of any characters
As long as the first word in the query name is Zhang. No matter how many characters there are.
select * from Student_Info where Name like '张%'
[] Indicates the scope of filtering.
The middle of the query surname Zhang is a number and the third is a Chinese character.
select * from Student_Info where Name like '张[0-9]三'
The middle of the query surname Zhang is a number or letter, and the third is a Chinese character.
select * from Student_Info where Name like '张[0-9][a-z]三'
^ Means not
Query Zhang Mousan, that is, there cannot be a number in the middle.
select * from Student_Info where Name like '张[0-9]三'
Expand and replace the REPLACE keyword
update Student_Info set Name=replace(Name,'张','李')
In this way, all those with the surname Zhang are replaced by those with the surname Li.