我有四个 SQL Server 数据库表:
inventory
inventory2
bdo
details
结构如下:
存货
AllocationID MSISDN
1 3018440225
2 3028431115
库存2
AllocationID MSISDN
1 3011234567
2 3026440657
3 3454159650
BDO
BDO_ID BDO_MSISDN
1 3457076952
2 3005000475
细节
AllocationID MSISDN
3 3454159650
现在我需要从以下查询中获取记录:
select a.msisdn, b.bdo_id
from details a, bdo b, inventory c, inventory2 d
where
a.msisdn = 3454159650
and (a.allocationid = c.allocationid) or (a.allocationid = d.allocationid)
and (c.bdo_id = b.bdo_id) or (d.bdo_id = b.bdo_id)
此查询返回超过 1 个结果(全部完全相同)为什么会这样???如果我错了,请更正我的概念和查询。