$sql = "SHOW TABLES FROM `master` WHERE TABLES is NUMERIC ORDER BY RAND() LIMIT 1";
$result = mysql_query($sql);
答案 0 :(得分:2)
我不确定您是否可以使用show table获取结果。
但是,你绝对可以使用information_schema来实现相同的
SELECT * FROM information_schema.tables WHERE TABLE_SCHEMA = 'master'
AND CAST(TABLE_NAME AS UNSIGNED) <> 0
ORDER BY RAND() LIMIT 1;
要抑制截断数据警告,请使用regexp
使用以下查询SELECT * FROM information_schema.tables WHERE TABLE_SCHEMA = 'master'
AND TABLE_NAME REGEXP '^(-|\\+)?([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+|[0-9]+)$'
ORDER BY RAND() LIMIT 1;