Jump to content

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/264716-join-tables-from-different-databases/
Share on other sites

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

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.