日期:2014-05-17 浏览次数:20663 次
create table table1(id int, score int)
insert into table1
select 1, 60 union all
select 2, 50
declare @id int
select @id=3
select @id 'id',
isnull((select score
from table1
where id=@id),0) 'score'
/*
id score
----------- -----------
3 0
(1 row(s) affected)
*/
declare @id int
select @id=1
select @id 'id',
isnull((select score
from table1
where id=@id),0) 'score'
/*
id score
----------- -----------
1 60
(1 row(s) affected)
*/