I've tried that angellll...
The usernames are choosen randomly, but I get the same item every time a user is choosen. I want the items also to be randomly choosen.
Main Topics
Browse All TopicsI have this table, and want to select one random item from two random usernames:
ID - Username - Item
1 - Kupsi - Car
2 - Kupsi - House
3 - John - Cat
4 - Ben - Car
5 - Kupsi - Apple
6 - John - Shirt
7 - Ben - Hat
8 - Mike - Glass
I want the results to be:
John - Shirt
Kupsi - Apple
or
Kupsi - Car
John - Cat
or
Mike - Glass
Kupsi - House
etc...
I don't want the result to be
Kupsi - House
Kupsi - Car
or
John - Cat
John - Shirt
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
this one ic covering cases with 1 or more then 2 occurence of username.
select x.username, x.item, y.username, y.item
from
(select id, username, item, FLOOR(1 + (RAND()) * (SELECT MAX(id) FROM tst)) seq
from tst) AS x
LEFT JOIN (select id, username, item FROM tst) AS y on x.username <> y.username
order by x.seq
limit 1 ;
Business Accounts
Answer for Membership
by: angelIIIPosted on 2009-03-21 at 04:08:58ID: 23946767
please try this:
Select allOpen in new window