Home > Archive > PHP SQL > July 2007 > Newbie question about multiple databases
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Newbie question about multiple databases
|
|
|
| if i have this query:
SELECT * FROM books2006, books2007;
(books 2006 and 2007 have exactly the same fields.)
how can i tell if the data was retrieved from books2006 or books2007
(whitout changing anything in the databases) ?
in other words is there any way that along the information that i
retrieve from the fields (ex. author, date_published, isbn) that i
also get the name of the database from which i retrieved the
information?
thank you very much,
GD
| |
| Michael 2007-07-13, 10:00 pm |
| I think you mean different tables, not different databases. It's
distinctly more difficult to select information from separate
databases in the same query (if not impossible). In any case, I think
the best case to deal with your problem is the PHP function
mysql_fetch_field http://www.php.net/mysql_fetch_field. It returns an
object, so you can call:
$table = mysql_fetch_field($result, $colNum)->table; to get the table
name of the colum in position $colNum.
Hope that helps!
| |
| Paul Lautman 2007-07-14, 7:01 pm |
| Michael wrote:
> I think you mean different tables, not different databases. It's
> distinctly more difficult to select information from separate
> databases in the same query (if not impossible). In any case, I think
> the best case to deal with your problem is the PHP function
> mysql_fetch_field http://www.php.net/mysql_fetch_field. It returns an
> object, so you can call:
> $table = mysql_fetch_field($result, $colNum)->table; to get the table
> name of the colum in position $colNum.
>
> Hope that helps!
Oh it is just SO difficult to get information from separate databases in the
same query:
SELECT * FROM database1.books2006, database2.books2007;
Wasn't that just so difficult - nearly impossible!
http://dev.mysql.com/doc/refman/5.0...qualifiers.html
| |
|
| On Fri, 13 Jul 2007 19:04:33 -0000, Michael <dimo414@gmail.com> wrote:
>I think you mean different tables, not different databases. It's
>distinctly more difficult to select information from separate
>databases in the same query (if not impossible). In any case, I think
>the best case to deal with your problem is the PHP function
>mysql_fetch_field http://www.php.net/mysql_fetch_field. It returns an
>object, so you can call:
>$table = mysql_fetch_field($result, $colNum)->table; to get the table
>name of the colum in position $colNum.
>
>Hope that helps!
thank you very much for your response.
You are right i meant different tables, not databases!! sorry about
that.
GD
|
|
|
|
|