Hive in the wildcard

% Represents any number of characters

select * from user where username like '%huxiao';   
select * from user where username like 'huxiao%';   
select * from user where username like '%huxiao%';   

_ Represents one character

select * from user where username like '_';  
select * from user where username like '______';    
select * from user where username like 'huxia_';    
select * from user where username like 'h_xiao';  

If I really want to check the% or _, how to do it? Use escape, behind the escape character% or _ not as a wildcard, and note that there is no escape character in front of% and _ wildcard characters still play a role

select username from gg_user where username like '%xiao\_%' escape '\';  
select username from gg_user where username like '%xiao\%%' escape '\';  

Commonly used '' to do the escape character, but can also use other symbols.

Guess you like

Origin www.cnblogs.com/QFKing/p/11869339.html