使用RAND()php mysql在限制ID之间的随机ID

时间:2010-08-22 09:56:50

标签: php mysql random limit

任何人都知道如何使用RAND()php msql

在限制ID之间使用Random wallpaperid

我使用它,但它的RAND()整个数据库

$sql_wallpaper = "SELECT * FROM wallpaper WHERE RAND()>0.9 ORDER BY RAND() LIMIT 0,5";
$res_wallpaper = mysql_query($sql_wallpaper);

请回复

1 个答案:

答案 0 :(得分:2)

你是说这个吗?

$sql_wallpaper = "SELECT * FROM wallpaper WHERE id>Min AND id<Max ORDER BY RAND() LIMIT 1";
$res_wallpaper = mysql_query($sql_wallpaper);