一个sql连接问题
表A
(
BuyID int,(1,2,3)
SellID int(4,5,6)
)
表B
(
PeopleID int,(1,2,3,4,5,6)
AA nvarchar(20)(a,b,c,d,e,f,g)
)
表A和表B 用BuyID ,SellID 和PeopleID相连。
例如:我现在想取出AA所有,不要用union all
[解决办法]
表A
(
BuyID int,(1,2,3)
SellID int(4,5,6)
)
表B
(
PeopleID int,(1,2,3,4,5,6)
AA nvarchar(20)(a,b,c,d,e,f,g)
)
你的数据,看不懂.
[解决办法]
select
b1.AA as BuyName,
b2.AA as SellName
from
A,B b1,B b2
where
a.BuyID=b1.PeopleID and a.SellID=c.PeopleID
[解决办法]
表A
(
BuyID int,(1,2,3)
SellID int(4,5,6)
)
表B
(
PeopleID int,(1,2,3,4,5,6)
AA nvarchar(20)(a,b,c,d,e,f,g)
)
表A和表B 用BuyID ,SellID 和PeopleID相连。
例如:我现在想取出AA所有,不要用union all
select b.aa from 表A a,表B b where charindex(a.BuyID,b.PeopleID)> 0 and charindex(a.SellID,b.PeopleID)> 0