有两个表
第一个表为员工表,两个字段,ID与姓名
ID XM
1 张三
2 李四
3 王五
..........
第二个表为业务表,三个字段,工作内容\操作人\核对人
GZNR CZR HDR
打文件 1 2
..........
上第一条记录的意思是 张三是操作员,李四是核对人,工作是打文件.
用SELECT语句怎么显示打文件 张三 李四 ??????多谢高手们
第一个表为员工表,两个字段,ID与姓名
ID XM
1 张三
2 李四
3 王五
..........
第二个表为业务表,三个字段,工作内容\操作人\核对人
GZNR CZR HDR
打文件 1 2
..........
上第一条记录的意思是 张三是操作员,李四是核对人,工作是打文件.
用SELECT语句怎么显示打文件 张三 李四 ??????多谢高手们
where 表2.CZR=a.id and 表2.HDR=b.id
(
select a.zgnr,b.xm as czr from 表2 a,表1 b
where a.czr=b.id
) e,
(
select c.zgnr,d.xm as hdr from 表2 c,表1 d
where c.czr=d.id
) f
where e.zgnr = f.zgnr
(
[ID] int,
XM nvarchar(8)
)create table #t2
(
GZNR nvarchar(20),
CZR int,
HDR int
)
insert into #t1
select 1,'张三'
union all
select 2,'李四'
union all
select 3,'王五'insert into #t2
select '打文件',1,2select 工作内容=GZNR,操作人=(select XM from #t1 where A.CZR=[ID]),
核对人=(select XM from #t1 where A.HDR=[ID])
from #t2 Adrop table #t1
drop table #t2