Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

generating a random number

 
   Database Help (Home) -> mySQL RSS
Next:  Alternative to self-joins??  
Author Message
nobody30

External


Since: Jan 15, 2005
Posts: 15



(Msg. 1) Posted: Sat Feb 12, 2005 11:40 pm
Post subject: generating a random number
Archived from groups: mailing>database>mysql (more info?)

is it possible to generate a random number within an sql script rather
than the client specifying which random row to select?

 >> Stay informed about: generating a random number 
Back to top
Login to vote
db_rookie

External


Since: Feb 12, 2005
Posts: 2



(Msg. 2) Posted: Sat Feb 12, 2005 11:40 pm
Post subject: Re: generating a random number [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

How about using rand()?

SELECT whatever FROM atable
ORDER BY rand() LIMIT 1

 >> Stay informed about: generating a random number 
Back to top
Login to vote
nobody30

External


Since: Jan 15, 2005
Posts: 15



(Msg. 3) Posted: Sun Feb 13, 2005 12:40 am
Post subject: Re: generating a random number [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

db_rookie wrote:
 > How about using rand()?
 >
 > SELECT whatever FROM atable
 > ORDER BY rand() LIMIT 1
 >

no wonder i couldn't find it. i searched for random().
thanks
 >> Stay informed about: generating a random number 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Random select - Hi, When I do a select with a limit I get always the same records. Usually this is the desidered effect. But now I want to do a random select. So every time I do a select I should get a different set of results. What is the best way to achieve this..

The total number of locks exceeds the lock table size - I get the above error from MySQL. What is going on, is that I have a InnoDB table "filltable", into which I am doing a lot of INSERTs in parallel (populating a data warehouse). In addition, at some point during the ongoing INSERT process, I ...

Best way to issue hundreds of inserts/updates??? - Using mysql 4.0.23- What is the best way to execute several (hundreds of) inserts and updates? Rather than issuing tons of individual inserts and updates, can I send the strings to a text file and then have mysql do them all?? IE : query.txt insert..

MySQL freezes, brings XP machine to a grinding halt - I've been using MySQL for a while for fairly light database development on my XP machine. Currently, I am just starting a new project and have experienced some big problems with MySQL today both on my office machine and at home where running a particular...

login as user 'root' but do not have root privlages and my.. - Hi gang: I'm experiencing a problem with MySQL -- I updated MySQL from version 4.1.0 to 4.1.10 and now when I login as root it doesn't show all the databases I should have access to, nor it doesn't recognize me being logged in as root (via..
   Database Help (Home) -> mySQL All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]