I have a DB table that has a member ID field and a level field...

There can be duplicate member IDs because they can have multiple steps

There can be duplicate step numbers because multiple members can be on the same step

But there should NEVER be a duplicate combination of memberID and Step...

It was brought to my attention today through a support person that there are instances where this is true though...

While I know I need to figure out what is causing it, I first need to determine how many cases of this there are, so I can use that info to help track down the issue.

What I don't know, is how to write a query that will pull out only the records that have duplicate combinations of the memberID and the Step, without listing the entire table with several thousand records...

Could someone help me out with how this query should be structured?

Thanks in advance.

Douglas

Member Avatar for diafol
SELECT member_id, level, count(level) FROM steps GROUP BY member_id,level HAVING COUNT(level) > 1

Thank you ardav,

I appreciate your response, and assuming that it was correct, there were no other instances of the issue. I did a manual scan of the file as well, and didn't see any duplicates, although those would be extremely easy to miss.

And I also believe I found the source of the issue, so all should be well.

thanks again.

Douglas

Member Avatar for diafol

Are we solved?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.