日期:2014-05-18  浏览次数:20471 次

我要随机调几条数据
我要随机调几条数据,但是只在前500条之内随机啊
我是这样写的,大家看看有什么不对的地方吗??
$sql = "SELECT * FROM `kj_sell`
WHERE itemid >= (SELECT floor( RAND() * ((SELECT MAX(itemid) FROM `kj_sell`)-(SELECT MIN(itemid) FROM `kj_sell`)) + (SELECT MIN(itemid) FROM `kj_sell`)))  
ORDER BY rand() LIMIT 10;";
$query = mysql_query($sql);
while ($row = mysql_fetch_assoc($query)){
$id=$row['itemid'];
$ttls=$row['title'];


echo "<a href=".$url.">".$ttls."</a><br />";
  }

------解决方案--------------------
top 500 order by newid()