所以我试图在我的sql命令中使用INNER JOIN,因为我试图用每列的文本值替换外键ID号。但是,当我使用INNER JOIN时,“Standards”的列总是给我相同的值。以下是我开始的内容
SELECT Grade_Id, Cluster_Eng_Id, Domain_Math_Eng_Id, Standard
FROM `math_standards_eng`
WHERE 1
并返回此(这很好)。请注意,标准值的值是不同的
Grade_Id Cluster_Eng_Id Domain_Math_Eng_Id Standard
103 131 107 Explain equivalence of fractions in special cases...
104 143 105 Know relative sizes of measurement units within o...
当我尝试使用Inner Join时,Grade_Id,Cluster_Eng_Id和Domain_Math_Eng_Id的值会从数字更改为实际文本。但是,标准列值似乎返回相同的值。这是我的代码:
SELECT
grades_eng.Grade, domain_math_eng.Domain, cluster_eng.Cluster,
math_standards_eng.Standard
FROM
math_standards_eng
INNER JOIN
grades_eng ON math_standards_eng.Grade_Id = grades_eng.Id
INNER JOIN
domain_math_eng ON math_standards_eng.Domain_Math_Eng_Id
INNER JOIN
cluster_eng ON math_standards_eng.Cluster_Eng_Id
这是我运行查询时得到的结果:
Grade Domain Cluster Standard
3rd Counting and cardinality Know number names and the count sequence Explain equivalence of fractions in special cases...
3rd Expressions and Equations Know number names and the count sequence Explain equivalence of fractions in special cases...
3rd Functions Know number names and the count sequence Explain equivalence of fractions in special cases.
4th Counting and cardinality Know number names and the count sequence Know relative sizes of measurement units within o...
4th Expressions and Equations Know number names and the count sequence Know relative sizes of measurement units within o...
标准的文本值继续显示每个等级的相同值,我不知道为什么。 3将继续显示相同的内容,然后下一个等级将更改为新值并反复重复。最后,每个表与标准具有1:M的关系,因为它们在标准表中多次出现。任何建议将不胜感激。
答案 0 :(得分:1)
您错过了=
和INNER JOIN
上domain_math_eng
的{{1}}部分。我希望有类似的东西:
cluster_eng