cgm225 Posted March 17, 2008 Share Posted March 17, 2008 Is there a way to, all at once, query two different tables in two different databases? Quote Link to comment Share on other sites More sharing options...
Naez Posted March 17, 2008 Share Posted March 17, 2008 You mean joining tables from different databases? Not that I know of. Quote Link to comment Share on other sites More sharing options...
cgm225 Posted March 17, 2008 Author Share Posted March 17, 2008 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? Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 17, 2008 Share Posted March 17, 2008 try this one example tell me what you get please......... <?php $sql="SELECT * FROM gallery_database WHERE DATE_ADD(NOW(),timestamp - INTERVAL, 31 DAYS)"; $sql_result=mysql_query($sql); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.