文章摘要
这篇文章介绍了使用SQL语言从数据库表`User_Detail`中查询用户信息。代码使用`CASE`语句对多个字段(包括电话、姓名、注册日期和地址)进行处理,若字段为空则返回“暂无”,否则返回实际值。这种处理方式旨在确保数据完整性,确保返回结果清晰易读。文章重点突出了SQL查询的逻辑和字段处理方法,帮助读者理解如何在实际应用中处理用户数据。
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
© 版权声明
文章版权归作者所有,未经允许请勿转载。