1.like How to use

1. rule of grammar :

* The format is A like B, among A Is a string ,B It's an expression ,
Is it possible to use B To exactly match A Content of , In other words, can it work B This expression is used to express A All content of , Pay attention to this and the rlike There is a difference . The result returned is True/False.
* B Only simple match symbols can be used  _ and %,”_” Represents any single character , character ”%” Represents any number of characters
* like Is matched by character , use B from A The first character of the starts matching , So even if one character is different .
2. Operation type : strings
3. Usage description : If the string A Or string B by NULL, Return to NULL; If the string A Conform to expression B
  Regular syntax of , Then it is TRUE; Otherwise FALSE. Pay special attention NULL Value matching , The returned result is not FALSE and TRUE, It is null, In fact, in addition to is null ,is
not null, Other relational operators only need to encounter null Value appears , It's all back NULL, instead of TRUE/FALSE.
hive (default)> select 'abcde' like 'abc'; OK false hive (default)> select
null like '%'; OK NULL hive (default)> select 'abc' like null ; OK NULL
4. Case study :

'foobar' LIKE 'foo' The value of is FALSE, and 'foobar' LIKE 'foo___' The value of is TRUE, 'foobar' LIKE
'foo%' The value of is TRUE. To translate %, Please use \(% Match one % character ). If the data contains a semicolon , You want to match it , You need to escape , image 'a\;b'
hive (default)> select 'abcde' like 'abc'; OK false hive (default)> select
'abcde' like 'abc__'; OK true hive (default)> select 'abcde' like 'abc%'; OK
true hive (default)> select 'abcde' like '%abc%'; OK true hive (default)>
select 'abcde' like 'bc%'; OK false hive (default)> select 'abcde' like '_bc%';
OK true hive (default)> select 'abcde' like '_b%'; OK true
5. matters needing attention : Negative comparison NOT A LIKE B( use A NOT LIIKE B it's fine too ), Results and like The result is relative .
Of course, the premise is to exclude the emergence null problem ,null Except for this wonderful work .
hive (default)> select 'abcde' like 'abc'; OK false hive (default)> select not
'abcde' like 'abc'; OK true hive (default)> select 'abcde' not like 'abc'; OK
true hive (default)> select null like '%'; OK NULL hive (default)> select not
null like '%'; OK NULL hive (default)> select null not like '%'; OK NULL
2. RLIKE A detailed explanation of the use of comparator

1. rule of grammar :

* A RLIKE B , express B Is it in A Just inside . and A LIKE B, Then it means B Is it A.
* B You can use the JAVA All regular expressions in , Specific regular rule reference java, Or other standard regular syntax .
2. Operation type : strings
3. Usage description : If the string A Or string B by NULL, Return to NULL; If the string A accord with JAVA regular expression B Regular syntax of , Then it is TRUE; Otherwise FALSE.
hive (default)> select 'footbar' rlike '^f..]+r$'; OK false hive (default)>
select 'footbar' rlike '^f.*r$'; OK true hive (default)> select 'foobar' rlike
'foo'; -- Notice the same expression , Match with regular OK true hive (default)> select 'foobar' like
'foo';-- Notice the same expression , use like Matching failed OK false hive (default)> select '123456' rlike
'^\\d+$'; OK true hive (default)> select null rlike '.*'; OK NULL
3.NOT A LIKE B And A not like B

  1. not..like yes like The negative usage of , If like When matching results true, be not..like When matching results of false, On the contrary, it is also the result and relative .
Of course, the premise is to exclude the emergence null problem ,null Except for this wonderful work ,null The results are all null value .
hive> select 1 from t_fin_demo  where NOT 'football' like 'fff%';         1
hive>select 1 from t_fin_demo where 'football' not like 'fff%'; 1 hive> select
1 from t_fin_demo where 'football' like 'fff%';
4. about like And rlike,not like,like not Comparative summary of the use of

   1.Rlike
Function and like The function is roughly the same ,like Yes, only simple expression matching is supported (_%), and rlike Standard regular expression syntax is supported . So if you're good at using regular expressions , Recommended use rlike, More powerful . be-all like Matches can be replaced with rlike. conversely , No .
But pay attention :like It's character by character match from the beginning , It's all matched , however rlike It is not , It can be matched from any part , And not all of them match .
hive (default)> select 'foobar' like 'foo'; OK false hive (default)> select
'foobar' like 'foo'; OK false hive (default)> select 'foobar' like 'oo%'; OK
false hive (default)> select 'foobar' rlike 'foo'; OK true hive (default)>
select 'foobar' rlike '.oo.*'; OK true
   2. NOT A LIKE
B yes LIKE The result is negative , If like When matching results true, be not..like When matching results of false, On the contrary, it is also the result and relative . It can also be used in practice A NOT
LIKE B, So is it LIKE The negation of , And NOT A LIKE B equally . Of course, the premise is to exclude the emergence null problem ,null Except for this wonderful work ,null The results are all null value .

   3. In the same way NOT RLIKE Use of , So is it NOT  A  RLIKE  B That's right RLIKE The negation of .
Of course, the premise is to exclude the emergence null problem ,null Except for this wonderful work ,null The results are all null value .

5.regexp And rlike equally

Technology
©2019-2020 Toolsou All rights reserved,
( Essence )2020 year 7 month 30 day Wechat applet Use of modules Fiddler Simulate request sending and modifying response data element-ui+vue-treeselect Verification of drop down box Vue + Element-ui Drop down box for el-select Get extra parameters Python read Excel A column | Transfer deposit json subversion ! Never take a nap longer than this time ! Watch out for fatal diseases …( Essence )2020 year 8 month 15 day redis database StackExchange.Redis in Set type (C# edition )jmeter-while Summary of controller use Go language Array initialization and basic operations mysql Recursively finds all child nodes of the parent class