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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.