注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 科普系列之-使用Windows的..
 帮助

使用ISNULL函数合并表


2007-06-27 11:28:22
 标签:函数 SQL ISNULL   [推送到技术圈]

一、语法
ISNULL ( check_expression , replacement_value )
1、参数
      check_expression:
      将被检查是否为 NULL 的表达式。check_expression 可以为任何类型。
      replacement_value :
      当 check_expression 为 NULL 时要返回的表达式。replacement_value 必须是可以隐式转换为 check_expresssion 类型的类型。
 
2、返回类型
      返回与 check_expression 相同的类型。
 
3、备注
      如果 check_expression 不为 NULL,则返回它的值;否则,在将 replacement_value 隐式转换为 check_expression 的类型(如果这两个类型不同)后,则返回前者。
 
二、合并表
 t1:
name                              quan
ab 119
abc 210
bc 3
bb 30
 
t2:
name                               quan
ab 125
abc 222
ac 30
bc 67
bb 89
ad 44
 
希望合并成这种形式:
name                     gs                 hn
ab 119 125
abc 210 222
ac 30
bc 3 67
bb 30 89
ad 44
 
select isnull(t1.name,t2.name) as name ,t1.quan as gs,t2.quan as hn
from sort_gs t1 full join sort_hn t2
on t1.name = t2.name

 
三、ISNULL()相当与ORACLE中NVL()




    文章评论
 
2007-06-27 22:09:04
SQL的哦。

不错,顶一下。

 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: