免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2086 | 回复: 1
打印 上一主题 下一主题

isnull困惑 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-25 19:22 |只看该作者 |倒序浏览
有一个表:
Table UserInfo                                                                               
UserID        UserName        UserEmail                UserType        UserAddress
=====================================
1        Winder        winder@gmail.com        1        3
2        David        david@yahoo.com        3        1
7        Jimmy        jimmy@sina.com        2                       
10        Simon        simon@sina.com        2        9
11        Mary                                        5              4
12        Lily        lily@abc.com        6        10
15        Lucy                        1        4
19        Ender        ender@yahoo.com        1                       
20        Alex        alex@Yahoo.com        5        5

要求:查询返回UserInfo表中所有信息,Null用Unknow代替
我用select UserID,UserName,isnul(UserEmail,'UNKNOWN'),UserType,isnull(UserAddress,'UNKNOWN')
from UserInfo
确总是提示说vchar类型的'UNKNOWN'转化成int出错,想想到也是这样的,因为useraddress是int型的,哪位高人帮忙解决一下我的问题

论坛徽章:
0
2 [报告]
发表于 2007-03-25 19:43 |只看该作者
呵呵,改ISNULL()为IFNULL()函数即可
不知道怎么用的话就看手册吧 http://imysql.cn/docs/MySQL_51_zh/mysql_51.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP