Determining whether the value of the field is null

       In Java, if it is determined whether a string is empty, you can use public static boolean isBlank (String str) apache StringUtils class determination, simple. However, in MySQL is no such tools, there is provided a method of whether the value of a field is empty judgment. First introduced two functions:

  •  ISNULL (exper) determines whether exper is empty, it returns 1; 0 otherwise
  •  length (exper) returns the number of bytes occupied exper string (coded by impact). If empty, returns 0

     To two examples provided below:

SELECT ISNULL(null); -- 1
SELECT LENGTH(trim(' ')); -- 0

      The combination of these two functions, we can easily determine a value for the field is empty:

- determining whether the method is empty 
the SELECT 
the CASE  the WHEN ( the ISNULL (Exper) = . 1 ) || (the LENGTH (TRIM (Exper)) = 0 ) THEN  ' empty ' 
    the ELSE  ' not empty ' 
the END  AS Result

Guess you like

Origin www.cnblogs.com/east7/p/12215871.html