Friday, March 28, 2008

select statement for multiple databases (no replies)

Hi guys!

I would like to make a complex MySQL Select-Statement!

The Situation:

I have many databases with the same MySQL Structure (some tables with same keys etc).
All Databases have the same prefix (vb_)

I want to do a query on the table posts (vb_posts), existing in each database.

The Problem:
I want to have all posts, sorted by the date/time (column post_datetime) and I need all rows in one select. And I need to know some more columns and the database the row belongs to!

I don't know if there's a solution in just one query.

I also thought about making a query for each database and put it into an Array (The Script is PHP based). But I need a high performance solution and I don't know if Array's will affect the performance!

Presently I make an update of a new table every 15 minutes and get put all posts in there, but I don't think this is the best solution, isn't it?

I hope you can help me!

Greetz
Robert