MS Access SQL 语句
情况是这样的,我是当地学区的网络开发人员,我的前任构建了一个自定义应用程序来跟踪孩子的考试成绩。我不是sql专家,所以我尊重大师!
我在 MS Access 中构建了以下表格:
- 评估 - 这是技能表的总体类别(即数学、阅读等)
- 技能 - 这些是个人测试并按评估 ID 分类
- 掌握 - 学生分数;当前显示技能 ID
下面是我现在的表格。最后一张桌子就是我想要的。
评估表
asstID asstName
1 Math
2 Reading
3 Literature
技能表
skillID skillName asstID
80 Vocabulary 3
81 Addition 1
82 Grammar 2
掌握表
masteryID stuID score skillID
20 st001 89 82
21 st001 96 81
22 st001 100 80
23 st002 88 81
24 st002 74 80
25 st002 99 82
掌握表 - 我想要它是什么。
masteryID stuID score skillID asstID
20 st001 89 82 2
21 st001 96 81 1
22 st001 100 80 3
23 st002 88 81 1
24 st002 74 80 3
25 st002 99 82 2
基本上,我有几千名学生需要将 asstID 添加到掌握表中。
我正在寻求创建 SQL 语句的帮助,我可以将其放入 MS Access 中,该语句将显示与当前表中的 SkillID 相对应的 asstID。
感谢任何帮助。
请不要问我们为什么使用 MS Access,这正是他在构建应用程序时使用的
here's the situation, I work as the web dev for a local school district and my predecessor built a custom app to track kids' test scores. I'm no sql expert, so I defer to the masters!
I have the following tables built in MS Access:
- Assessment - this is the overarching category for the skills table (ie, math, reading, etc)
- Skills - these are the individual tests and are categorized by assessment ID
- Mastery - student scores; currently displays the skills ID
Below, are my tables as they are right now. The very last table is what I'd LIKE to have it be.
Assessment Table
asstID asstName
1 Math
2 Reading
3 Literature
Skills Table
skillID skillName asstID
80 Vocabulary 3
81 Addition 1
82 Grammar 2
Mastery Table
masteryID stuID score skillID
20 st001 89 82
21 st001 96 81
22 st001 100 80
23 st002 88 81
24 st002 74 80
25 st002 99 82
Mastery Table - What I want it to be.
masteryID stuID score skillID asstID
20 st001 89 82 2
21 st001 96 81 1
22 st001 100 80 3
23 st002 88 81 1
24 st002 74 80 3
25 st002 99 82 2
Basically, I have a couple thousand students that need to have the asstID added to the Mastery Table.
I'm looking for help creating a SQL statement I can put into MS Access that will display the asstID that corresponds to the skillID in the current table.
ANY help is appreciated.
Please don't ask why we're using MS Access, that's just what he used when he built the app
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在查询设计器(QBE 或按示例查询)网格中,您将添加 Mastery 表和 Skills 表,并确保
Mastery.SkillID
和Skills 之间存在关系线。技能ID
。In the Query designer (QBE or Query-By-Example) grid, you would add the Mastery table and the Skills table and ensure that there was a relationship line between
Mastery.SkillID
andSkills.SkillID
.怎么样:
How about:
这就是我最终用来更新 4k+ 行的方法。在运行此命令之前,我在数据库本身中创建了一个名为
asstID
的新列。解释:
- 循环遍历 tblMastery 和从每一行获取 tblMastery.skillID 的值
- 连接到 tblSkills 和获取 tblSkills.asstID 的值,其中 tblSkills.skillID 与 tblMastery.skillID 匹配
- 使用 tblSkills.asstID 中的匹配值更新 tblMastery.asstID
希望这对某人有帮助。 :)
This is what I ended up using to update my 4k+ rows. Before running this, I created a new column in the DB itself named
asstID
.Explanation:
- loop through tblMastery & grab the value of tblMastery.skillID from each row
- connect to tblSkills & grab the value of tblSkills.asstID where the tblSkills.skillID matches tblMastery.skillID
- update tblMastery.asstID with the matching value from tblSkills.asstID
Hope this helps someone. :)