求一条简单SQL语句

netvsj2ee 2008-03-25 11:24:59
select SEC_LEVEL from S_TELLER_SEC where teller='0016'
select SEC_LEVEL from S_ROLE_SEC where ROLE_ID='1'

表S_TELLER_SEC字段SEC_LEVEL和teller
表S_ROLE_SEC字段SEC_LEVEL和ROLE_ID

能不能用一条SQL语句查出SEC_LEVEL的数据,谢谢大家,请帮忙~
...全文
108 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
huangjh_love 2008-03-25
Select a.SEC_LEVEL From  S_TELLER_SEC a Left Outer Join S_ROLE_SEC b on a.SEC_LEVEL=b.SEC_LEVEL
where teller='0016' or ROLE_ID='1'
回复
xthe 2008-03-25
select a.SEC_LEVEL
from S_TELLER_SEC a
inner join S_ROLE_SEC b
on a.SEC_LEVEL=b.SEC_LEVEL
where a.teller='0016' and b.ROLE_ID='1'
回复
liangCK 2008-03-25
[Quote=引用 1 楼 dawugui 的回复:]
引用楼主 netvsj2ee 的帖子:
select SEC_LEVEL from S_TELLER_SEC where teller='0016'
select SEC_LEVEL from S_ROLE_SEC where ROLE_ID='1'

表S_TELLER_SEC字段SEC_LEVEL和teller
表S_ROLE_SEC字段SEC_LEVEL和ROLE_ID

能不能用一条SQL语句查出SEC_LEVEL的数据,谢谢大家,请帮忙~


select SEC_LEVEL from S_TELLER_SEC where teller='0016'
union all
select SEC_LEVEL from S_ROLE_SEC where…
[/Quote]
回复
忆轩辕 2008-03-25
select a.SEC_LEVEL from S_TELLER_SEC as a inner join S_ROLE_SEC as b on a.SEC_LEVEL = b.SEC_LEVEL
where a.teller='0016' and b.ROLE_ID='1'
回复
dawugui 2008-03-25
[Quote=引用楼主 netvsj2ee 的帖子:]
select SEC_LEVEL from S_TELLER_SEC where teller='0016'
select SEC_LEVEL from S_ROLE_SEC where ROLE_ID='1'

表S_TELLER_SEC字段SEC_LEVEL和teller
表S_ROLE_SEC字段SEC_LEVEL和ROLE_ID

能不能用一条SQL语句查出SEC_LEVEL的数据,谢谢大家,请帮忙~
[/Quote]

select SEC_LEVEL from S_TELLER_SEC where teller='0016'
union all
select SEC_LEVEL from S_ROLE_SEC where ROLE_ID='1'

回复
hery2002 2008-03-25
UNION ALL
回复
yyyyzzzz_2002 2008-03-25

SELECT SEC_LEVEL
FROM (
SELECT SEC_LEVEL FROM S_TELLER_SEC WHERE teller ='0016'
UNION ALL
SELECT SEC_LEVEL FROM S_ROLE_SEC WHERE ROLE_ID='1'
) a

--或者要求无重复数据,此句性能不好
SELECT SEC_LEVEL
FROM (
SELECT SEC_LEVEL FROM S_TELLER_SEC WHERE teller ='0016'
UNION
SELECT SEC_LEVEL FROM S_ROLE_SEC WHERE ROLE_ID='1'
) a
回复
相关推荐
发帖
MS-SQL Server
创建于2007-09-28

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2008-03-25 11:24
社区公告
暂无公告