MySQL InnerJoin - 条款上的未知列

时间:2015-11-15 19:08:17

标签: mysql join

我已经搞乱了MySQL一段时间了,得到了我所有的数据库设置,现在我试图和InnerJoin一起加入这些表,但是我一直在接受这个" Unknown专栏条款"错误,尝试谷歌搜索,但我的代码似乎是正确的。

以下是查询的内容:

    select 
        CharacterName, ClassName, PerkName
    FROM 
        rpgcharacter
    INNER JOIN 
        class ON rpgcharacter.idClass = class.idClass
    inner join 
        perks on rpgcharacter.idRPGCharacter = perklist.idRPGCharacter; 

错误

  

代码:1054。未知栏' perklist.idRPGCharacter'在' on条款'

1 个答案:

答案 0 :(得分:1)

啊,我看到我做错了什么,显然因为我以前没有比较甚至提到查询找不到表,这是我找到的解决方案。

select 
    rpgcharacter.CharacterName, class.ClassName,
    perks.PerkName, skills.SkillName
from 
    perklist
inner join 
    rpgcharacter on perklist.idRPGCharacter = rpgcharacter.idRPGCharacter
inner join 
    class on rpgcharacter.idClass = class.idClass
inner join 
    perks on perklist.idPerks = perks.idPerks
inner join 
    skilllist
inner join 
    skills on skilllist.idSkill = skills.idSkills 
           and skilllist.idRPGCharacter = rpgcharacter.idRPGCharacter
where 
    perklist.idRPGCharacter = 3