Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find random, THEN order by date?

Status
Not open for further replies.

adelante

Programmer
May 26, 2005
82
DK
Doing a blog thing, but it is only updated once every month with about 10 new records, so I was making a little script to select some random records, but it doesn't seem to be possible to select 3 random records first, and THEN order them by date. Or is it??

Here is what I got right now:

SELECT date,text FROM blog ORDER BY RAND() LIMIT 3

I have tried to place ",date" different places but it doesn't work.

Any ideas would help
Thanks!!
 
You could try:

SELECT rand() as rand, date, text
FROM blog
ORDER BY rand
LIMIT 3;

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
whoops, ORDER BY rand,date asc limit 3;

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top