从不同的表的数据库获取数据 [英] Getting data from database from different tables

查看:291
本文介绍了从不同的表的数据库获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建使用(ASP + WML)这款移动门户网站/应用程序都是我需要生成的通过在某年某学期学生所学课程的列表。



我有以下表格:





我从以前的页面具有下列参数:

 字符串StudentId = Request.Params [StudentId]; 
字符串年= Request.Params [年];
串学期= Request.Params [学期];




  • 的(年度<值/ code>),要么是2011或2012。

  • 的(学期)的值或者是第一或第二或夏。

  • StudentId )的值是学生表之前从ID中提取的数



作为表中的数据的样本。



< IMG SRC =http://i.stack.imgur.com/uNUQL.jpgALT =在这里输入的形象描述>



我困在这里

 字符串的connectionString = @数据源= .\SQLEXPRESS; AttachDbFileName = | DataDirectory目录| \ Uni.MDF; + 
集成安全=真;用户实例=真;
字符串的queryString =???????????????????????????;



我想获得一个页面显示,用户在注册(在某一学期的课程)。
的信息将在URL中新的页面,在这里的信息将显示在以后通过。



是这样的:

 第一学期2010 
学生:阿林里兹克

信贷马克
AAA 3 65
BBB 3月23日
CCC 3 65
DDD 3 58
的课程名称号EEE 3 70

你这个semster GPA为3.12

修改



我如何将打印在页面中的信息以后呢?



我可以如何做到这一点?我试图创建一个视图,但我不知道为什么它不工作。



我不能改变表或数据库结构。



感谢您提前。


解决方案

 选择ST .firstname +''+ st.lastname,se.year,c.coursename,c.credits,ri.mark 
学生ST
内部联接RegisteredIn里的ri.studentid = st.id
上se.id = ri.semesterid $内部联接学期SE b $ b内部联接上c.id = se.courseid

$ b课程ç
$ b

该查询会给你的名字,一年,课程名,学分和标记。



您需要编写GPA计算另一个查询或你可以计算出上述获得的数据在Web服务器上。


I'm creating this mobile portal/application using (ASP + WML) were I need to generate a list of courses taken by a student in certain semester in a certain year.

I have the following tables:

I have from a previous page the following parameters:

string StudentId = Request.Params["StudentId"];
string Year = Request.Params["Year"];
string Semester = Request.Params["Semester"];

  • the values of the (Year) is either "2011" or "2012".
  • the values of (Semester) is either "First" or "Second" or "Summer".
  • the values of (StudentId) is a Number extracted before from id in Students table.

As a sample of the data inside the tables.

I'm stuck here

string connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFileName=|DataDirectory|\Uni.MDF;" +
            "Integrated Security=True;User Instance=True";
           string queryString =" ??????????????????????????? " ;

I want to get a page to show the courses that the user is registered in (in a given semester). The information will be later passed in a URL to new page where the info will be shown.

Something like:

First Semester  2010
Student : Arin Rizk

Course Name     No. of Credit      Mark
    AAA                3            65
    BBB                3            23
    CCC                3            65
    DDD                3            58
    EEE                3            70

Your GPA for this semster is 3.12

Edit

how I will print the the info in the page later ?

How can I do it? I tried to create a view but I don't know why its not working.

I can't change the tables or the DB structure.

Thank you in advance.

解决方案

select st.firstname + ' ' + st.lastname,se.year, c.coursename,c.credits,ri.mark 
from students st 
inner join RegisteredIn ri on ri.studentid=st.id
inner join semester se on se.id=ri.semesterid
inner join Courses c on c.id=se.courseid

this query will give you the name, year, coursename, credits and marks.

You need to write another query for gpa calculation or you could calculate on your web server with the data obtained above.

这篇关于从不同的表的数据库获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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