文章摘要
本文介绍了如何使用SQL语言对数据库中的用户信息表进行查询,并通过CASE语句处理字段值。具体来说,查询中使用CASE语句分别处理了Telephone、Name、CreateDate和Address字段,当这些字段为空时,返回结果为“暂无”,否则显示实际值。这种处理方式能够有效避免空值对查询结果的影响,确保数据的一致性和完整性。
select (CASE when (TelPhone IS NULL OR TelPhone=”) then ‘暂无’ else TelPhone end) as TelPhone,(CASE when (Name is null or Name=”) then ‘暂无’ else Name end) as name,(CASE when (CreateDate IS NULL OR CreateDate=”) then ‘暂无’ else CreateDate end) as CreateDate,(CASE when ([Address] IS NULL OR [Address]=”) then ‘暂无’ else [Address] end) as [Address] from User_Detail
select (CASE when (TelPhone IS NULL OR TelPhone=”) then ‘暂无’ else TelPhone end) as TelPhone,(CASE when (Name is null or Name=”) then ‘暂无’ else Name end) as name,(CASE when (CreateDate IS NULL OR CreateDate=”) then ‘暂无’ else CreateDate end) as CreateDate,(CASE when ([Address] IS NULL OR [Address]=”) then ‘暂无’ else [Address] end) as [Address] from User_Detail
© 版权声明
文章版权归作者所有,未经允许请勿转载。


