Saturday, 24 August 2013

Why the query returns more than one result?

Why the query returns more than one result?

I have four SQL Server database tables:
inventory
inventory2
bdo
details
Structure is as:
inventory
AllocationID MSISDN
1 3018440225
2 3028431115
Inventory2
AllocationID MSISDN
1 3011234567
2 3026440657
3 3454159650
BDO
BDO_ID BDO_MSISDN
1 3457076952
2 3005000475
Details
AllocationID MSISDN
3 3454159650
Now I need to get the records from following query:
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)
This query returns more than 1 result (all exactly same) why is it so???
if I am wrong please correct my concepts and query.

No comments:

Post a Comment