Reputation: 8626
I have following table:
MovieMaster:
DVDBinSlotInfo:
There can be repeated movieid in DVDBinSlotInfo table.
I just want to take them differently through query,
i.e.
Movienames which are not repeated for particular kioskid and
Movienames which are repeated for particular kioskid
for this i made following query:
select MovieName from MovieMaster where MovieID in(select MovieID from DVDBinSlotInfo
where KioskID='901' and Status='DVD' )
above was for all movieids
below is for distinct (not repeated):
select MovieName from MovieMaster where MovieID in(select distinct MovieID from
DVDBinSlotInfo where KioskID='901' and Status='DVD' )
but unfortunatly , with both the queries it shows Movienames which are not repeated for particular kioskid .
I want to show for repeated movieids also.
Means for example movieid 10 is reapeated thrice in DVDBinSlotInfo then it should show its name thrice in the result.
Please help me.
Upvotes: 0
Views: 30
Reputation: 11464
You need to use INNER JOIN, (I guess)...
SELECT MovieName from MovieMaster
INNER JOIN DVDBinSlotInfo ON MovieMaster.MovieId = DVDBinSlotInfo.MovieId
WHERE KioskID='901' and Status='DVD'
Upvotes: 1