我知道这是一个基本的东西,但SQL是我的一个严重弱点......
我有以下查询(" query1")
select
SC.statues, SC_some_real_code
from
[corpdb_gs].[dbo].[Simple_Codes] SC
inner join
[corpdb_gs].[dbo].[real_simple_essentials] RSE
on
SC.statues = RSE.se_statutes
AND
SC.some_real_code = RSE.se_statutes_reason
我只需要返回表[db2].[dbo].[statusYo]
中的行
statusYo.code = "query1".SC.statues
AND
statusYo.reason = "query1".SC.some_real_code
帮助?
答案 0 :(得分:1)
select * from [db2].[dbo].[statusYo] query2
inner join
(select
SC.statues as statues , SC.some_real_code as some_real_code
from
[corpdb_gs].[dbo].[Simple_Codes] SC
inner join
[corpdb_gs].[dbo].[real_simple_essentials] RSE
on
SC.statues = RSE.se_statutes
AND
SC.some_real_code = RSE.se_statutes_reason) query1
on query1.statues =query2.code
and query1.some_real_code=query2.reason
这对你有用......