From: Joaquín <javalpi@xxxxxxxxx>
I need query tables that are in two different databases
mysql_select_db("DB1", $conn_1);
mysql_select_db("DB2", $conn_2);
$result_t1 = mysql_query("SELECT * FROM `Table1inDB1`",$conn_1);
$row_t1 = mysql_fetch_assoc($result_t1);
$result_t2 = mysql_query("SELECT * FROM `Table2inDB2`",$conn_2);
$row_t2 = mysql_fetch_assoc($result_t2);
Although Joaquín said his issue is [Fixed], I write these queries as:
SELECT * FROM DB1.TableInDB1
SELECT * FROM DB2.TableInDB2
(with and without link_identifiers I believe), so I was wondering about best
practices.
I can see if you already have code written without the DB in the FROM
clause, it could be easier to have multiple links.
I haven't really used multiple links, but I ran into issues with multiple
databases and consistently setting the correct DB, so now if I know I'll be
using multiple DB's, I just write the query with the DB in the FROM clause.
(A prior fix was to select the DB before each query. But if it was already
selected, it seemed like a waste {according to my "by inspection" profiler}.
So I started using the DB in the FROM clause.)
Are there any recommendations regarding best practices between:
1) using multiple links and table.field (or table) notation
versus
2) database.table.field (or database.table) notation?
_________________________________________________________________
Local listings, incredible imagery, and driving directions - all in one
place! http://maps.live.com/?wip=69&FORM=MGAC01
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php