Is it possible to connect to multiple databases and do query on tables from each database? I can't find any examples.
Yes.
Just make sure you specify which db connection to use for each query. If you omit this, then the last opened db connection will be used.
mysql_query()
I have come across dialects of SQL which permit queries with this syntax
SELECT a.field1, b.field1 FROM tableA IN database1 a INNER JOIN tableB IN database2 b ON ... etc ....
You can only try and see if yours permits this or similar
hth