gpt4 book ai didi

php - 从 mysql_fetch_row() 中排除结果

转载 作者:太空宇宙 更新时间:2023-11-03 12:11:04 25 4
gpt4 key购买 nike

我有以下列出数据库中所有表的代码,我想做的是从列表中排除表名。

$listtables = mysql_query("SHOW TABLES");
if($listtables){
while ($row = mysql_fetch_row($listtables)) {
echo "{$row[0]}<br>";
}
}

哪些输出说:

1
2
3
4
5

现在我应该怎么做才能从列表中排除 3?感谢您的帮助。

最佳答案

您可以为此目的使用 SQL where 子句。

SHOW TABLES WHERE tables_in_db_name <> '3';

如果需要排除多个:

SHOW TABLES WHERE tables_in_db_name NOT IN ('3', '5');

db_name 替换为您的数据库名称。

关于php - 从 mysql_fetch_row() 中排除结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24188815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com