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
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
ASKER
simply i have to show only two result for each category, not all the result
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is the output you want
aaaaa,1,1
aaaaa,1,2
As an example?
The distinct option example will eliminate duplicates which you have!
aaaaa,1,1
aaaaa,1,2
As an example?
The distinct option example will eliminate duplicates which you have!
ASKER
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.
Can you be a little more specific about the output you expect?