EMPTY()

Description

Checks whether the input string is empty. A string is considered non-empty if it contains at least one byte, even if this is a space or a null byte.

Syntax

  1. > EMPTY(str)

Arguments

ArgumentsDescription
strRequired. both CHAR and VARCHAR are supported.

Returned Values

Returns 1 for an empty string or 0 for a non-empty string.

Examples

  1. > drop table if exists t1;
  2. > create table t1(a varchar(255),b varchar(255));
  3. > insert into t1 values('', 'abcd');
  4. > insert into t1 values('1111', '');
  5. > select empty(a),empty(b) from t1;
  6. +----------+----------+
  7. | empty(a) | empty(b) |
  8. +----------+----------+
  9. | 1 | 0 |
  10. | 0 | 1 |
  11. +----------+----------+