Gurpinder Posted June 25, 2012 Share Posted June 25, 2012 hi i need to join 2 tables from 2 different databases. I understand that i have to write the full database.dbo.table thing out but I dont know what to put. my database is hosted on godaddy.com this is the hostname provided by godaddy: dynamicdb.db.8000072.hostedresource.com the other database is: staticdb.db.8000072.hostedresource.com the query i am running in php is: $orders_query=mysql_query("SELECT invoice.Name, order.ID, order.PO_Number, order.Open_Date, order.Closed_Date, order.Status FROM _____????_____ AS order JOIN _____????_____ AS invoice ON order.Invoice_To = invoice.ID WHERE invoice.Sales_Rep='{$_SESSION['Username']}' ORDER BY ID DESC "); I don't know how to write the full location of the database in "_____????_____". CAn someone help? thx Quote Link to comment https://forums.phpfreaks.com/topic/264716-join-tables-from-different-databases/ Share on other sites More sharing options...
requinix Posted June 25, 2012 Share Posted June 25, 2012 You can't join databases across servers. Quote Link to comment https://forums.phpfreaks.com/topic/264716-join-tables-from-different-databases/#findComment-1356736 Share on other sites More sharing options...
Gurpinder Posted June 25, 2012 Author Share Posted June 25, 2012 not different servers.....2 different databases on the same server Quote Link to comment https://forums.phpfreaks.com/topic/264716-join-tables-from-different-databases/#findComment-1356789 Share on other sites More sharing options...
kicken Posted June 25, 2012 Share Posted June 25, 2012 not different servers.....2 different databases on the same server Not according to the host names you provided. To join between two databases on the same server, you just do dbname.tablename. (the .dbo part is a Microsoft SQL Server thing). For example: SELECT * FROM `userdb`.`users` u INNER JOIN `orderdb`.`orders` o ON u.userid=o.userid Quote Link to comment https://forums.phpfreaks.com/topic/264716-join-tables-from-different-databases/#findComment-1356872 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.