左加入两个MYSQL数据库

I am trying to join two Mysql databases, but I am getting the following error:

SELECT command denied to user 'sj'@'localhost' for table 'joborders'

below are how my databases are listed:

  • db1 - database sjb table joborders
  • db - database sj Table users

And this is my code:

    $query = "SELECT db1.users.username,  db.joborders.usern, db.joborders.job_title ".
    "FROM db.joborders LEFT JOIN db1.users ".
"ON db.joborders.usern = dbi.users.username"; 

    $result = mysql_query($query) or die(mysql_error());

    while($row = mysql_fetch_array($result)){
echo $row['usern']. " - ". $row['job_title'];

I have tried re-writing this several different ways but i just keep getting the same error.

You might have a typo in your table names

"ON db.joborders.usern = dbi.users.username"; 

replace i with 1

instead of telling you that the 'dbi' table doesn't exist, the error message indicates that the command was denied -- as though you don't have permissions

Post the schemas if you are not sure,also is usern a column? Are you sure db1.users_username, db.joborders_usern the table names are not like this,with underline?

db1 - database sjb table joborders

db - database sj Table users

From this info names should be sjb.joborders,sj.users and so on.