1524
asked on
mysql query question
I have an myql table which holds the names and email addresses of visitors to my site that have entered a competition, Now that the competition is closing I need to randomly select 3 winners from the database.
I figured this could probably be done with a simple sql query?
thanks in advance
table structure below:
# Database : `board`
# -------------------------- ---------- ---------- ----------
#
# Table structure for table `cd_submissions`
#
CREATE TABLE cd_submissions (
user_email varchar(255) NOT NULL default '',
user_name varchar(100) NOT NULL default '',
UNIQUE KEY cd_submissions_ux1 (user_email)
) TYPE=MyISAM;
I figured this could probably be done with a simple sql query?
thanks in advance
table structure below:
# Database : `board`
# --------------------------
#
# Table structure for table `cd_submissions`
#
CREATE TABLE cd_submissions (
user_email varchar(255) NOT NULL default '',
user_name varchar(100) NOT NULL default '',
UNIQUE KEY cd_submissions_ux1 (user_email)
) TYPE=MyISAM;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for your help, much appreciated
select user_email, user_name
from cd_submissions
order by Rand()
limit 3
p.s. This will return a different result each time it is run ... I hope that is what you wanted