我想检索驻留在不同数据库中的两个不同字段。我的数据库连接设置是这样的:
define ('DB_HOST', 'ipaddress1');
define ('DB_USER', 'username1');
define ('DB_PASSWORD', 'password1');
define ('DB_DATABASE', 'ecbooks');
$db_wink = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, TRUE) or die("Connection Error: " . mysql_error());
mysql_select_db(DB_DATABASE) or die("Error connecting to Winkstore DB. " . mysql_error());
// DB configuration parameters : magonwink
define ('DB_REMOTE_HOST', 'ipaddress2');
define ('DB_REMOTE_USER', 'username2');
define ('DB_REMOTE_PASSWORD', 'password2');
define ('DB_REMOTE_DATABASE', 'magsonwink');
$db_magson = mysql_connect(DB_REMOTE_HOST, DB_REMOTE_USER, DB_REMOTE_PASSWORD, TRUE) or die("Connection Error: " . mysql_error());
mysql_select_db(DB_REMOTE_DATABASE, $db_magson) or die("Error connecting to magson wink DB. " . mysql_error());
define ('CMS_DB_HOST', 'ipaddress3');
define ('CMS_DB_USER', 'username3');
define ('CMS_DB_PASSWORD', 'password3');
define ('CMS_DB_DATABASE', 'mawinkcms');
$db_rp = mysql_connect(CMS_DB_HOST, CMS_DB_USER, CMS_DB_PASSWORD, true) or die("Connection Error: " . mysql_error());
mysql_select_db(CMS_DB_DATABASE, $db_rp) or die("Error connecting to DB. " . mysql_error());
但是当我使用这个查询时
SELECT ecbooks.user.user_name AS field1, mawinkcms.purchase.USER_NAME AS field2 FROM ecbooks.user,mawinkcms.purchase
$result = mysql_query($query, $db_wink) or die("Couldn't execute query: " . mysql_error());
while($row = mysql_fetch_assoc($result)){
$users[] = $row;
}
我收到一个错误,无法执行查询。提前致谢。