mysql - SQL - Selecting data that is the same in multiple rows for a particular key -


i have dataset below:

key     user     step --------------------- 123     geoff    1 123     geoff    2 123     john     3 456     jane     1 456     jane     2 456     jane     3 456     jane     4 

what need select key user same in steps (there can between 1 5 steps in dataset). in example above need query return key 456. appreciated!

instead of comparing min(user) , max(user), can well:

select tablename.key tablename group tablename.key having count(distinct d.user) = 1; 

count(distinct d.user) should more descriptive use case.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -