Link to home
Start Free TrialLog in
Avatar of Ganesh Thandapani
Ganesh Thandapani

asked on

MySQL to get Limited value from each category.

I have user table which contains user_name, import_id, user_category

user_name   import_id   user_category
aaaaa                 1                 1
bbbbbb              1                 1
aaaaa                 1                 1
bbbbbb              1                 1
aaaaa                 1                2
bbbbbb              1                 2
aaaaa                 1                 2
bbbbbb              1                 2
aaaaa                 1                 3
bbbbbb              1                 3
aaaaa                 1                 3
bbbbbb              1                 4
aaaaa                 1                 4
bbbbbb              1                 5

in which i have to show only two values in each category as a result
Avatar of Patrick Bogers
Patrick Bogers
Flag of Netherlands image

Hi

Can you be a little more specific about the output you expect?
Avatar of Ganesh Thandapani
Ganesh Thandapani

ASKER

simply i have to show only two result for each category, not all the result
ASKER CERTIFIED SOLUTION
Avatar of Sharath S
Sharath S
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is the output you want
aaaaa,1,1
aaaaa,1,2
As an example?
The distinct option example will eliminate duplicates which you have!
ok nice, the distinct is used to avoid duplicates. Another condition if i want to take two or three values for each category how can i do that, any idea please.
Post your expected result.