有人可以告诉我如何保存两个数据库表中的字段吗?php/mysql SHOW COLUMNS from table1 and table2
也能正常工作为一个表:
$link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
mysql_select_db($db) or die("Can not connect.");
$result = mysql_query("SHOW COLUMNS FROM ".$table." WHERE Field NOT IN
('ID','Key','Text');");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field']."; ";
$i++;
}
}
$csv_output .= "\n";`
我需要从两个不同的表中的字段。我在同一台机器上有两个数据库。表格中的字段名称不同。
这是不工作:
$link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
mysql_select_db($db) or die("Can not connect.");
mysql_select_db($db2) or die("Can not connect.");
$result = mysql_query("SHOW COLUMNS FROM ".$table." , ".$table2." WHERE Field NOT IN
('ID','Key','Text');");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field']."; ";
$i++;
}
}
$csv_output .= "\n";
字段 “ID”, “键” 和 “文本” 仅在DB1存在。
有什么错误? – 2012-08-09 10:00:30