Check the sql query bellow. Here in SearchedUserItems
table there is a foreign key column named SearchedUserID
which is primary key in another table called SearchedUsers
. So basically in this query i am saying give me top 100 items from table SearchedUserItems
which items have matching SearchedUserID
from inner query list select top 10 SearchedUserID from SearchedUsers
.
So this gives me top 100 items from all top 10 SearchedUserID
matched but my goal is:
I want to get top 100 items from each SearchedUserID
matched from SearchedUsers
table. From current query i am getting total 100 matched items only but i need 100 items from each matched SearchedUserID
from SearchedUsers
table. How can i apply this for each thing
in this query?
If you are not clear about question plz ask me. I tried my best to explain
select top 100 * from SearchedUserItems where SearchedUserID in (
select top 10 SearchedUserID from SearchedUsers
)