Hi, The below 3 table join with select works fine.
I am returning 5 random users who are watching other users. See previous topic.
What I want is to only return the users who are watching more than 10 other users. I presume it's count(WatchedPr ofileID)>5 but if I try to add it here I get errors. I have tried with having count etc.
It might be a syntax thing I am doing wrong.
When I join the tblWatches to the main query
Any pointers would be great
Thanks in advance
Richard
Code:
SQLQuery="Select top 5 L.accept,etc,etc, " SQLQuery= SQLQuery & "FROM tblAppsLoginDatabaseBySmo L INNER JOIN tblAppsProfilesDatabaseBySmo P ON L.UserId = P.UserId " SQLQuery= SQLQuery & " inner join tblWatches T ON P.UserId = T.WatchingUserID " SQLQuery= SQLQuery & " and p.userid in (Select WatchingUserID from tblWatches where WatchedProfileID <>0 )" SQLQuery= SQLQuery & " order by NEWID() "
What I want is to only return the users who are watching more than 10 other users. I presume it's count(WatchedPr ofileID)>5 but if I try to add it here I get errors. I have tried with having count etc.
Code:
SQLQuery= SQLQuery & " and p.userid in (Select WatchingUserID from tblWatches where WatchedProfileID <>0 and (count(WatchedProfileID) >10))"
When I join the tblWatches to the main query
Any pointers would be great
Thanks in advance
Richard
Comment