2个表:
A表:学生信息表,有学生ID 教师ID 学生信息等字段。
B表:教师信息表,有教师ID,教师姓名,教师信息等字段。如何实现读取学生所有信息后,显示的是教师的姓名,而不是ID呢?

解决方案 »

  1.   

    select B.教师姓名 from A,B where A.教师ID = B.教师ID and 学生信息 = "***"
      

  2.   

    select B.教师姓名 from A,B where A.教师ID = B.教师ID and A.学生信息 = "***"
      

  3.   

    一个关联查询,你去SQL里面的视图两个表拉一下就知道了
      

  4.   

    在 javabean中该如何写呢?
    在jsp 页面中又该如何显示呢?
    我的bean是 
    public Collection getAllStudent()throws Exception
    {
    Statement stmt=con.createStatement();
    ResultSet rst=stmt.executeQuery("select * from Student");
    Collection ret=new ArrayList();
    while(rst.next())
    {
    Student temp=new Student();
    temp.setStudentid(rst.getString("studentid"));
    temp.setTeacherid(rst.getString("teacherid")) ;
    ………………
      

  5.   

    2个表:
    A表:学生信息表,有学生ID 教师ID 学生信息等字段。
    B表:教师信息表,有教师ID,教师姓名,教师信息等字段。如何实现读取学生所有信息后,显示的是教师的姓名,而不是ID呢?sql语句应该写在哪里呢?jsp页面?还是bean里面?