sql—当我尝试选择列的修剪值不为null的行时,它仍然返回具有null值的行(雪花)

mfpqipee  于 2021-07-24  发布在  Java
关注(0)|答案(2)|浏览(366)
SELECT Client_id, first_name, mobile_number 
FROM client_table 
WHERE trim(mobile_number) IS NOT NULL
krugob8w

krugob8w1#

trim不会使值为null,而是使其成为空字符串

create or replace table table2 (province varchar);
insert into table2 (province) values
    ('  '),
    (' ');

    select trim(province) from table2 where trim(province,' ') = '';

https://docs.snowflake.com/en/sql-reference/functions/trim.html

yquaqz18

yquaqz182#

如果mobile\u number的值可以是null或空格,我通常会这样做:where coalesce(trim(mobile\u number),“”)<>“”

相关问题