求 sql 语句 急
用的是Access数据库,假使两个表
设计部:design
ID UName
1 王老虎
2 李俊
3 章军报
4 为小宝
5 王老虎
6 章军报
7 为小宝
8 王老虎
IT部:it
ID UName
1 王老虎
2 李俊
3 章军报
4 为小宝
5 王老虎
6 章军报
7 为小宝
8 王老虎
我想用group by UName把同时两个表的人员列出来,该怎么写sql语句啊?
------解决方案----------------------估计是这样,没有调试过
select UName
from design
where exists(select * from it UName = design.UName)
group by UName
------解决方案--------------------//Access调试通过
select UName
from
(
select UName
from design
union all
select UName
from it
)
group by UName
------解决方案--------------------select distinct a.UName From
(Select UName from design
union
Select UName from it
) a
------解决方案--------------------是不是这个,你试试。
SELECT DISTINCT dbo.design.UName
FROM dbo.design FULL OUTER JOIN
dbo.design it ON dbo.design.产品编号 = it.UName
GROUP BY dbo.design.UName