表自链接问题,在线等,谢谢!
有一个表,结构如下
采购申请单号 采购单号 采购类型PURCHASEAPPLYNO PURCHASENO PURCHASETYPEPA001 P001 1PA001 P002 2
select * from [tb] where [采购申请单号]in (select [采购申请单号] from tb where [采购单号]='P001')
[解决办法]
select 采购单号from tb twhere 申请单号 = (select 申请单号 from tb where 采购单号 = ? group by 申请单号) and 采购单号 <> ? -- ? 是你的查询的采购单号
[解决办法]
select *from tb twhere exists(select 1 from tb where 采购申请单号=t.采购申请单号 and 采购单号='xxxx')