首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

sql2000语句

2013-07-01 
求一个sql2000语句现有pdkcb表,有两个盘点号,pd_haop130324001pd_haop130324002求查询出p130324001,

求一个sql2000语句
现有pdkcb表,有两个盘点号,pd_hao='p130324001'  pd_hao='p130324002'
求查询出p130324001,p130324002这两个盘点号中bian_hao,pi_hao相同的品种 sql语句
[解决办法]



select * from 
(select * from pdkcb where pd_hao='p130324001') t1
inner join 
(select * from pdkcb where pd_hao='p130324002') t2
on t1.bian_hao = t2.bian_hao and t1.pi_hao = t2.pihao




[解决办法]

select * from (
select * from pdkcb where pd_hao in('p130324001','p130324002'))
a,
select * from pdkcb where pd_hao in('p130324001','p130324002')
b
where a.bian_hao = b.bian_hao
and a.pi_hao = b.pi_hao

[解决办法]
select * from 
pdkcb  a inner join pdkcb b
on a.bian_hao = b.bian_hao and a.pi_hao = b.pihao  
where a.pd_hao='p130324001'
and b.pd_hao='p130324002'
[解决办法]


select * 
from pdkcb as a 
where a.pd_hao in('p130324001','p130324002') 
and exists(select 1 from pdkcb where bian_hao=a.bian_hao and pi_hao=a.pi_hao and pd_hao <>b.pd_hao  and pd_hao in('p130324001','p130324002'))

热点排行
Bad Request.