Associate
- Joined
- 29 May 2003
- Posts
- 2,038
- Location
- Cambridge
I've just done a site for a client that pulls a news story at random out of the database and displays it on the home page. I've used the following query:
Admittedly, there are currently only three stories in the database, but the random effect works fine on my development setup using MySQL 4.1.20 but fails when the page is uploaded to the client's server - it only ever shows the first story. Their host provides MySQL 3.32.54, so my first guess is that this older version didn't support the RAND() command.
Does anybody know if this is the case and if so, how it could be worked-around?
Code:
SELECT ehfeaturednews.newsid, ehfeaturednews.picture, ehfeaturednews.imagealt, ehfeaturednews.textlong AS excerpt, ehfeaturednews.link
FROM ehfeaturednews
ORDER BY RAND() LIMIT 1
Does anybody know if this is the case and if so, how it could be worked-around?