当前位置: 代码迷 >> Oracle技术 >> 如何把两个查询结果连接起来
  详细解决方案

如何把两个查询结果连接起来

热度:686   发布时间:2016-04-24 08:43:10.0
怎么把两个查询结果连接起来
select name from table_A where id in (select t_id from table_b where id=81)

查询结果:
-------
名称A
名称B

select t_num from table_b where id=81

查询结果:
-------
3
2

------我需要以下的结果
名称A 3
名称B 2

------解决方案--------------------
SQL code
select a.name,b.t_num from table_A a,(select t_id,t_num from table_b where id=81))b where a.id=b.t_id
------解决方案--------------------
SQL code
select a.name ,b.t_num  from table_A a ,table_b bwhere a.id = b.t_id and b.id=81
------解决方案--------------------
select a.name ,b.t_num
from table_A a ,table_b b
where a.id = b.t_id 
and b.id=81

------解决方案--------------------
select a.name , b.t_num
from table_a a , table_b b
where a.id = b.t_id and b.id = 81
------解决方案--------------------
SQL code
SELECT     a.NAME,b.t_numFROM table_A AS a    INNER JOIN table_b AS b ON a.ID=b.t_idWHERE b.ID=81
------解决方案--------------------
select tt.name,
ss.t_num
from
(select name from table_A t where id in (select t_id from table_b where id=81)) tt,
(select t_num from table_b s where id=81) ss
------解决方案--------------------
SQL code
select A.name, B.t_num    from table_A A  left join table_b B   on A.id = B.id  where  B.id=81