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? Link to comment https://forums.phpfreaks.com/topic/96490-mysql-query-that-searches-two-tables-in-two-different-databases/ 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. Link to comment https://forums.phpfreaks.com/topic/96490-mysql-query-that-searches-two-tables-in-two-different-databases/#findComment-493836 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? Link to comment https://forums.phpfreaks.com/topic/96490-mysql-query-that-searches-two-tables-in-two-different-databases/#findComment-493837 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); ?> Link to comment https://forums.phpfreaks.com/topic/96490-mysql-query-that-searches-two-tables-in-two-different-databases/#findComment-493848 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.