$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());
有什么加速 php 的建议吗?
最佳答案
请参阅 Bill Karwin 的演示文稿。幻灯片 142 及以后。
http://www.slideshare.net/billkarwin/sql-antipatterns-strike-back
关于mysql - order by rand 的查询问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4644871/