I have two tables: 1) Games contains a list of games with data about each and 2) Comments has various user comments and ratings for the games.
I'm trying to return all the games for a user, where the user has not yet entered anything into the Comments table.
The following code is my best shot - but is returns several records for each game, since other people have Comments for those games. How do I return each game only once? (I'm using SQL Server 2005.)
SELECT C.GameID, C.UserID, C.CommentID,
(SELECT GameName FROM Games WHERE GameID = C.GameID ) as GameName,
(SELECT MinAge FROM Games WHERE GameID = C.GameID ) as MinAge
FROM Comments C
WHERE (UserID != @UserID)
Many thanks,
Mark
I'm trying to return all the games for a user, where the user has not yet entered anything into the Comments table.
The following code is my best shot - but is returns several records for each game, since other people have Comments for those games. How do I return each game only once? (I'm using SQL Server 2005.)
SELECT C.GameID, C.UserID, C.CommentID,
(SELECT GameName FROM Games WHERE GameID = C.GameID ) as GameName,
(SELECT MinAge FROM Games WHERE GameID = C.GameID ) as MinAge
FROM Comments C
WHERE (UserID != @UserID)
Many thanks,
Mark