如何使用 PHP获取此 SQL 查询返回的行:
SET @r := (SELECT ROUND(RAND() * (SELECT COUNT(*) FROM mytable)));
SET @sql := CONCAT('SELECT * FROM mytable LIMIT ', @r, ', 1');
PREPARE stmt1 FROM @sql;
EXECUTE stmt1;
设置等于上述值$query
然后照常执行不会返回任何结果。mysql_query($query)
如何使用 PHP获取此 SQL 查询返回的行:
SET @r := (SELECT ROUND(RAND() * (SELECT COUNT(*) FROM mytable)));
SET @sql := CONCAT('SELECT * FROM mytable LIMIT ', @r, ', 1');
PREPARE stmt1 FROM @sql;
EXECUTE stmt1;
设置等于上述值$query
然后照常执行不会返回任何结果。mysql_query($query)