2012-04-11 64 views

回答

0

像這樣做,看看它是否工作

mysql_query('SET @r := (SELECT ROUND(RAND() * (SELECT COUNT(*) FROM mytable)));'); 
mysql_query('SET @sql := CONCAT('SELECT * FROM mytable LIMIT ', @r, ', 1');'); 
$resource = mysql_query('PREPARE stmt1 FROM @sql;EXECUTE stmt1;'); 

不要忘記逃跑的SQL的第二個指令

相關問題