PGSQL如何判断一个空值字段,并将NULL值修改为其它值

在使用pgsql时,想要取到某些字段不为空或者为空的数据,可以用以下方法:

1、不为空

Select * From table Where id<>''

Select * From table Where id!=''

2、为空

Select * From table Where id=''

Select * From table Where ISNULL(id)

如果字段是类型是字符串,用 id=''可以;如果是int型则用 ISNULL

如果需要将空值设置为其它值:
select COALESCE(b.price, 其它值) as price from fruit_sale b
发布了114 篇原创文章 · 获赞 47 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/Jmayday/article/details/103877603