dseslyh6662605 2013-09-17 17:02
浏览 18

左加入两个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.

  • 写回答

1条回答 默认 最新

  • duanci5913 2013-09-17 17:12
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP