select Instorage_Id,CompanyCode,CompanyNmae , Re
from 入库主表 a
where CompanyCode='AUN'
and exists(select 1 from from 入库明细表 where Instorage_Id=a.Instorage_Id
and SKU in ('A-1200','A-2301','E-4004')
from 入库主表 a
where CompanyCode='AUN'
and exists(select 1 from from 入库明细表 where Instorage_Id=a.Instorage_Id
and SKU in ('A-1200','A-2301','E-4004')
on a.Instorage_Id=b.Instorage_id and a.CompanyCode='AUN'and b.SKU in ('A-1200','A-2301','E-4004')
where a.Instorage_Id='AUN20070602001'
on a.Instorage_Id=b.Instorage_id and b.SKU in ('A-1200','A-2301','E-4004')
where a.Instorage_Id='AUN20070602001' and a.CompanyCode='AUN'
为什么会是AUN20070602001
它不是没有E-4004吗?
from 入库主表 a
where CompanyCode='AUN'and
exists
(select 1 from from 入库明细表 where Instorage_Id=a.Instorage_Id
and SKU in ('A-1200','A-2301','E-4004')
from 入库主表 a inner join 入库明细 b on a.Instorage_Id= b.Instorage_Id
where a.CompanyCode = 'AUN' and (b.Sku = 'A-1200' or b.Sku = 'A-2301' or b.Sku = 'E-4004')
and a.Instorage_Id = 'AUN20070602001'
返回:
Instorage_Id CompanyCode CompanyNmae Re
-------------------- ----------- ------------- -----------
AUN20070602001 AUN 康杰有限公司 备注(所影响的行数为 1 行)
select distinct a.*
from 入库主表 a inner join (
select Instorage_Id from 入库明细 where Sku = 'A-1200' or Sku = 'A-2301' or Sku = 'E-4004') b on a.Instorage_Id = b.Instorage_Id
where a.CompanyCode = 'AUN' and a.Instorage_Id = 'AUN20070602001'
返回:
Instorage_Id CompanyCode CompanyNmae Re
---------------- ----------- ------------ ---------
AUN20070602001 AUN 康杰有限公司 备注(所影响的行数为 1 行)
from 入库主表 a
inner join 入库明细 b on a.Instorage_Id= b.Instorage_Id
where a.CompanyCode = 'AUN'
and (b.Sku = 'A-1200' or b.Sku = 'A-2301' or b.Sku = 'E-4004')
and a.Instorage_Id = 'AUN20070602001'
select Instorage_Id,CompanyCode,CompanyNmae , Re
from 入库主表 a
where a.CompanyCode='AUN' and
exists
(select * from 入库明细 where Instorage_Id=a.Instorage_Id
and SKU in ('A-1200','A-2301','E-4004')) and a.Instorage_Id = 'AUN20070602001'
返回:
Instorage_Id CompanyCode CompanyNmae Re
---------------- ----------- ------------ ---------
AUN20070602001 AUN 康杰有限公司 备注(所影响的行数为 1 行)
on a.Instorage_Id=b.Instorage_id and a.CompanyCode='AUN'and b.SKU in ('A-1200','A-2301','E-4004')
where a.Instorage_Id='AUN20070602001'