2011-01-10 3 views
0
$totalrows = 10; 

$sql = "SELECT 
posts.Tags as tags, 
posts.OwnerUserId as postsid, 
posts.Id as postid, 
posts.Body as body, 
posts.Title as title, 
users.Id as userid, 
users.DisplayName as usersname 
FROM posts 
JOIN users ON posts.OwnerUserId = users.Id 
WHERE posts.Title != '' order by rand() asc limit " . $totalrows; 

$r = mysql_query($sql) or die(mysql_error()); 

Une suggestion pour accélérer php?problèmes de requête avec ordre par rand

+2

Vous venez de poser cette question plus tôt. http://stackoverflow.com/questions/4644600/order-by-rand-gets-trouble-for-large-posts – BoltClock

Répondre

0

Cochez cette ... $ limit = 10; $ start = 0; $ sql = « SELECT posts.Tags sous forme de balises, posts.OwnerUserId comme postsid, posts.Id comme postID, posts.Body comme corps, posts.Title comme titre, users.Id comme userid, utilisateurs .DisplayName en tant que nom d'utilisateur
FROM messages JOIN utilisateurs sur posts.OwnerUserId = users.Id WHERE posts.Title! = '' Commander par rand() asc limite ". $ start. ",". $ limite;

$ r = mysql_query ($ sql) ou die (mysql_error());

+0

Bonjour, J'ai essayé votre avis, il faut obtenir 30 secondes pour être ouvert – Dan