SELECT MIN(id), MAX(id) FROM tablename; Fetch the result into $a $id=rand($a[0],$a[1]); SELECT * FROM tablename WHERE id>='$id' LIMIT 1 转载于:https://blog.51cto.com/xuqin/925231