It is necessary to check the value of the field. If it contains: - empty string '' - or a string consisting of any number of spaces - or NULL, return 1, otherwise - 0.

How could this more elegantly be done in terms of code performance and compactness?

Only two ways come to mind:

SET @a=NULL; #SET @a=''; #SET @a=' '; # первый способ: SELECT @a IS NULL OR TRIM(@a)=''; # второй способ: SELECT CONCAT_WS('',TRIM(@a))=''; 
  • If you often have to do, maybe you should write your own function? - JVic 10:02 pm
  • 2
    trim(ifnull(@a,''))='' - Mike

0