Jump to content

MySQL query that searches two tables in two different databases...


cgm225

Recommended Posts

I have two tables in two different databases as such::

 

My album table in a gallery_database...

 

id  |  album_title  |  dir  |  timestamp

 

 

My notes table in a notes_database...

 

id  |  note_title  |  note  |  timestamp

 

 

I want to search both tables and return entries from the last thirty days (for an RSS script I am making).  I have been playing around with the following query which DOES return those entries, but seems to place the entires/rows from the notes table under the columns from the album table.

 

$query = "(SELECT * FROM gallery_db.albums WHERE datediff(now(),timestamp)<31) UNION (SELECT * FROM notes_db.notes WHERE datediff(now(),timestamp)<31)";

 

Any ideas?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.