查询多个表 - VB.Net/MS Access 2013 [英] Querying From Multiple Tables - VB.Net/MS Access 2013

查看:134
本文介绍了查询多个表 - VB.Net/MS Access 2013的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何从多个表?我正在尝试打印用户的答案表以在datagridview中显示。但是,我需要
来从三个不同的表中提取所需的数据:tblQuestions,tblQuizAnswers和tblQuizResults。




以下是每张表所需的列:



tblQuizAnswers:

- StudentID

- FirstName

- LastName

- pCourse

- CourseSubject

- QuizID1

- QuizTitle

- QuizNumber

- 答案

- DateTaken



tblQuizResults:

- QuizScore

- QPercentage



tblQuestions:

- ActualQuestion

- CorrectAnswer

- AnswerExplanation



这是表之间的共同点:



tblQuestions& tblQuizAnswers:

- QuizID / QuizID1

- QuizTitle / QuizTitle

- QuestionNumber / QuizNumber

- CourseSubject / CourseSubject

- CorrectAnswer / CorrectAnswer



tblQuestions& tblQuizResults:

- QuizID / QuizID1

- QuizTitle / QuizTitle

- CourseSubject / CourseSubject



tblQuizAnswers& tblQuizResults:

- StudentID / StudentID

- FirstName / FirstName

- LastName / LastName

- pCourse / pCourse

- CourseSubject / CourseSubject

= QuizID1 / QuizID

- QuizTitle / QuizTitle



所有三个表:

- QuizID

- QuizTitle

- CourseSubject



我还需要显示用户答案的​​相应数据。例如,用户对
特定测验的第一个问题的答案是字母A(这是唯一的数据)保存在数据库中),我需要在gridview中显示什么是选项A.

解决方案

有很多示例说明如何基于公共字段将多个表连接到单个查询中。请参阅以下链接以获取示例:


https://stackoverflow.com/questions/19367565/access-sql-inner-join-with-multiple-tables



How do I query from multiple tables? I am trying to print a user's answer sheet to show in a datagridview. However, I need to pull the needed data from three different tables: tblQuestions, tblQuizAnswers, and tblQuizResults.

Here are the columns I need from each table:

tblQuizAnswers:
-StudentID
-FirstName
-LastName
-pCourse
-CourseSubject
-QuizID1
-QuizTitle
-QuizNumber
-Answer
-DateTaken

tblQuizResults:
-QuizScore
-QPercentage

tblQuestions:
-ActualQuestion
-CorrectAnswer
-AnswerExplanation

Here's what's common between the tables:

tblQuestions & tblQuizAnswers:
-QuizID/QuizID1
-QuizTitle/QuizTitle
-QuestionNumber/QuizNumber
-CourseSubject/CourseSubject
-CorrectAnswer/CorrectAnswer

tblQuestions & tblQuizResults:
-QuizID/QuizID1
-QuizTitle/QuizTitle
-CourseSubject/CourseSubject

tblQuizAnswers & tblQuizResults:
-StudentID/StudentID
-FirstName/FirstName
-LastName/LastName
-pCourse/pCourse
-CourseSubject/CourseSubject
=QuizID1/QuizID
-QuizTitle/QuizTitle

all three tables:
-QuizID
-QuizTitle
-CourseSubject

I also need to show the corresponding data for the user's answer. For example, the user's answer for question number one for a particular quiz is letter A (and that's the only data that's being saved in the db), I need to show in my gridview what was option A.

解决方案

There are many examples that document how to join multiple tables into a single query based upon common fields. See the below link for an example:

https://stackoverflow.com/questions/19367565/access-sql-inner-join-with-multiple-tables


这篇关于查询多个表 - VB.Net/MS Access 2013的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆