【发布时间】:2019-09-06 10:31:00
【问题描述】:
我需要帮助来进行查询,该查询将使用联合中 select 1 的结果作为查询条件。
示例:
select * from table1 where name='xx'
union all
select * from table1 where Name=(select surname from table2 where surname='xx') -- (the name from first query)
这是我到目前为止得到的,但每次我查询它时,我只得到一行
Select a.client, a.voucher_no from agltaxtrans a left outer join agltaxtrans b on a.voucher_no=b.voucher_no where a.voucher_no=b.voucher_no
union all
select client, voucher_no from agltaxtrans where voucher_no IN (select voucher_cor from a49bontaxtranshist b left outer join agltaxtrans a on a.voucher_no=b.voucher_cor where b.voucher_cor=a.voucher_no)
【问题讨论】:
-
样本数据、期望的结果和数据库真的很有帮助。
-
嗨,欢迎来到 StackOverflow!请提供您的表格结构和表格数据、您想要的结果以及您目前得到的结果:)
-
stackoverflow.com/help/mcve,方便为您提供帮助!
标签: sql union outer-join