query two databases

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

lynx
New php-forum User
New php-forum User
Posts: 4
Joined: Fri Oct 25, 2002 12:53 pm

query two databases

Postby lynx » Fri Oct 25, 2002 12:59 pm

Hello,
I would like to know if there is a way to do a query on tables from two separate databases. Thanks.

DoppyNL

Postby DoppyNL » Fri Oct 25, 2002 10:49 pm

You can't.
I PHP that is, in mysql itself it is possible.
You will have to run 2 query's and combine them in PHP.

Greetz Daan

Jay

Postby Jay » Fri Oct 25, 2002 10:53 pm

DoppyNL wrote:You can't.
I PHP that is, in mysql itself it is possible.
You will have to run 2 query's and combine them in PHP.

Greetz Daan

I think you got it the other way around ;) In MySQL you can't, but in PHP you can. Run two separate queries and use PHP to combine and extract the data

DoppyNL

Postby DoppyNL » Fri Oct 25, 2002 11:00 pm

Sorry, but I got it right,
you can do this in the command line of mysql:

Code: Select all

select field1, field2 from database1.table1, database2.table2;

and will return the result. as if it where 2 tables in the same database.

PHP can't do this because the query function wants a database-connection wich has selected one database. So PHPmyAdmin can't do this either...

Greetz Daan

Jay

Postby Jay » Sat Oct 26, 2002 2:34 pm

Hmm, I see! Yes, I have seen that before! And, if I'm not mistaken, PHP can also do it then through access to the one database if the permissions are the same. I will have to give it another test, 'cos I remember doing something a while back!


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 6 guests

cron