Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find more than one entry for a given column ID 2

Status
Not open for further replies.

hapax

Programmer
Nov 10, 2006
105
0
0
US
I have a table named Comments.
It has columns CommentID, GameID, UserID.

I want to find out if any UserID has more than one CommentID for any given GameID (they shouldn't). Could someone please tell me a SELECT to accomplish this?

Many thanks
 
Try the following:

select count(commentId), UserId, GameID
From Comments
Group by UserID, GameID
Having Count(CommentId)>1

Hope this helps!

Thank you
Keerthana
 
SELECT GameID, UserID, COUNT(*)
FROM Comments
GROUP BY GameID, UserID
HAVING COUNT(*)>1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top