$sql = "SHOW TABLES FROM database";
我想排除表“用户”,“汽车”和“礼物”等。怎么办呢?
答案 0 :(得分:7)
您可以直接从information_schema
数据库查询表名。假设您的数据库名称位于变量$your_database_name
:
mysql_select_db("information_schema");
$sql = "SELECT TABLE_NAME
FROM TABLE
WHERE
TABLE_SCHEMA = '$your_database_name'
AND TABLE_NAME NOT IN ('users','cars','gifts')";
答案 1 :(得分:2)
SHOW TABLES FROM database_name WHERE tables_in_database_name NOT IN ('users');
如果你不想要汽车和用户
SHOW TABLES FROM database_name WHERE tables_in_database_name NOT IN ('users', 'cars');
答案 2 :(得分:1)
如果您不想显示表格,那么在echo
时您可以这样做:
while($row = mysql_fetch_array($res))
{
if($row[0] == 'users' || $row[0] == 'cars' || $row[0] == 'gifts')
continue;
else
echo $row[0];
}