Jump to content

Recommended Posts

I trying to join two tables in 2 separate databases, mainbill and demo. 

 

$query2 = "SELECT * FROM mainbill.notes inner join mainbill.notes ON mainbill.notes.id = demo.notes_list.bill_id";

When I run this query I get:

 

Not unique table/alias: notes.

 

Now I do not have a notes table in the demo database so I can't figure out what the problem is.  Both databases are on the same server.

Link to comment
https://forums.phpfreaks.com/topic/242080-problem-with-querying-from-2-databases/
Share on other sites

well to put it plainly, you can't however by indicating the database in your select query, MYSQL allows another database to be called...so that's not the issue here..

 

1. Are you sure that you can execute query's with the given connection information?

 

2. Which database are you using in your mysql_select_db?

 

here's the connect code right before that query:

$dbhost = "localhost";
$dbname = "xxxx_mainbill";
$dbuser = "xxxxx_yyyy";
$dbpass = "xxxxx";

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

Importantly, the dbuser and dbpassword is the same for the other database (demo)

Ok I'm sorry I think I just wasted all of your time.  I was not naming the databases correctrly.  for example the database is called

myusername_demo  NOT

demo

 

I a really sorry but at least I still needed the correct JOIN command which you guys did help me with so all is not lost!

Thanks again...

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.