master82 Posted July 12, 2007 Share Posted July 12, 2007 I have a table that consists of 6 fields tableid - unique auto incremental value code - a code given to each user userid - the unique id of the user time - unix timestamp of when the code was issued ip - the ip of the user when code was issued status - small description of why the code was given Now what I need to do is identify all the userids that appear with the same code only and list them, so that i can see if the same code is in use by multiple users. I know its probably something simple, but im having an off day Any help would be greatful Quote Link to comment Share on other sites More sharing options...
tapos Posted July 12, 2007 Share Posted July 12, 2007 u can use 'order by code' in the query -- Tapos Pal Quote Link to comment Share on other sites More sharing options...
master82 Posted July 12, 2007 Author Share Posted July 12, 2007 I have done (group by code) but that also shows every user who does have a code to themselves. Creating a long list! What i need (if possible) is to see ONLY those users who have the same code as another user, with the code they were given eg see Mr X with code 12345 and Mr Y with code 12345 but not Ms Z with code 54321 hope im explaining this right? Quote Link to comment Share on other sites More sharing options...
jitesh Posted July 12, 2007 Share Posted July 12, 2007 select * from `table` GROUP BY code having (count(userid) > 1) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.