【数据库问题】,如何实现以下功能
id name 档案号 1 统称 null 2 小李 1 3 小崔 2 4 小张 3 5 小赵 4
--当我传入档案号为2时 呈现如下数据-- id name 档案号-- 1 统称 null-- 3 小崔 2--当我传入档案号为4时 呈现如下数据-- id name 档案号-- 1 统称 null-- 5 小赵 4--当我传入档案号为10时 呈现如下数据-- id name 档案号-- 1 统称 null--因为档案号为10 是不存在的 所以只读取档案号为null的 --请高手为小弟解答下!谢谢declare @tb table (id int,name nvarchar(32),dn int)insert into @tb select 1,'统称',NULL UNION ALL SELECT 2,'小李',1UNION ALL SELECT 3,'小崔',2 UNION ALL SELECT 4,'小张',3UNION ALL SELECT 5,'小张',4 declare @id int set @id=4select * from @tb where dn = @idunion allselect * from @tb where dn is nullid name dn----------- -------------------------------- -----------5 小张 41 统称 NULL(2 行受影响)