last day (15 days later) » 

6:23 PM
The limit at the bottom of the query is obscuring the data and what you want to do. It appears that you want to break the relationship between the two columns
 
6:42 PM
Yeah, show ONE item per user, and only allow for category, say, 2 and 7 to be shown ONCE per query. :)
(thank you for offering your help, btw)
 
no problem
but you have to decided which ones you DONT want to see
so you are suggesting that you will exclude users if you already have a user with that category correct?
 
That could be an option. I simply don't want the category 1 and 5 to be shown more than once
and I don't want to show the same user more than once (well, twice wouldn't be bad, but the idea is just to spread the results as much as possible).
 
6:58 PM
you realize that "spread the results" doesnt make any logical sense right?
 
probbaly
Hmm
1 user per query
maximum 1 category if id is (X or X)
Because I fetch items based on users distance. This means, if I did not group by user, the results would contain ALL of user 1 items.
or well, I mean, i ORDER by
That is why I implemented "group by"
group by user_id
Problem 2:
The category, say, 2 and 5 is categories that fill 80% of the database.
If i perform my query now, 80% of the results will be from the same categories
My idea is, that if I can allow that the mainstream categories (say 2 and 5) will only be shown ONCE per query, the results will be more "spread"
Say the closest user is 2, the distance is 5000 meters. User 2 has 10 items. If I order by users distance, the query will be filled with 10 items of user 2.
That is, UNLESS, I group by user_id
Hope it makes sense.
 
i was with you until you brought distance into the mix
oh.. no.. i see what you are saying there
i get that you want to restrict some values, but want to let others come in
how about a union
ok.. wait a minute...
you say "one user per query"
and you want the top x categories for that user?
 
7:42 PM
Could you show an example in the fiddle? (sqlfiddle.com/#!2/0a4bad/1)
 

last day (15 days later) »