duanjie9630 2014-04-09 22:56
浏览 151
已采纳

左连接中的两个表都有id字段。 试图从第一个数据库中提取id字段,但是获取第二个数据库

Just updated my site from mysql_ to mysqli and broke a previously functioning query.

Im trying to pull the id from spins, as it increments by 1 each time, but I keep getting the player id instead, can someone tell me what Im doing wrong? I tried multiple variations of renaming spins to AS s.spins etc.

$query=$db->query("SELECT * FROM `spins` LEFT JOIN `players` ON `players`.id=`spins`.player ORDER BY `time` DESC LIMIT 30");

Im using the following to call the spin id, but get the players id instead.

  $content.='<td>'.$row['id'].'</td>';
  • 写回答

1条回答 默认 最新

  • doudi4621 2014-04-09 23:00
    关注

    Specifically name the fields in your query, something like :

    SELECT `spins`.id as spinsID FROM `spins` LEFT JOIN `players` ON `players`.id=`spins`.player ORDER BY `time` DESC LIMIT 30"
    
    $content.='<td>'.$row['spinsID '].'</td>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器