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

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

问题描述

我使用(ASP + WML)创建这个移动门户网站/应用程序,因为我需要生成一个学生在某一学期某一学期在某一年所学的课程列表。



我有以下表格:





我从上一页的以下参数:

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




  • code>)为「2011」或「2012」。

  • Semester

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


    $ b img src =https://i.stack.imgur.com/uNUQL.jpgalt =enter image description here>



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

    我想要一个页面来显示用户注册的课程)。
    该信息稍后将在URL中传递到将显示信息的新页面。



    如下:

      2010年第一学期
    学生:Arin Rizk

    课程名称学分数量
    AAA 3 65
    BBB 3 23
    CCC 3 65
    DDD 3 58
    EEE 3 70

    此学期的GPA为3.12

    编辑



    我将如何稍后在页面中打印信息?



    做吗?我尝试创建一个视图,但我不知道为什么它不工作。



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



    提前谢谢。

    解决方案

      .firstname +''+ st.lastname,se.year,c.coursename,c.credits,ri.mark 
    从学生st
    inner join注册在ri.studentid = st.id
    inner join semester se on se.id = ri.semesterid
    inner join课程c on c.id = se.courseid

    $ 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天全站免登陆