你可以采用VO的方式来编写JAVABEAN.SQL语句:三张表各自的主键进行关联了.

解决方案 »

  1.   

    select sno,sname,ssex,sage,sdept from student
    union
    select cno,cname,cpno,ccredit from course
    union 
    select sno,cno,grade from sc
      

  2.   

    select 
        a.sno,
        a.sname,
        a.ssex,
        a.sage,
        a.sdept,
        b.cno,
        b.cname,
        b.cpno,
        b.ccredit,
        c.grade
    from 
        student a,
        course b ,
        sc c
    where 
        a.sno = c.sno and b.cno = c.cno
        ...  --  网页中要输入的字段的条件
      

  3.   

    非常感谢楼上的两位但是我还要根据我网页中输入的数据来查询啊,
    就像是String sql="select * from student,course,sc where student.sno = '"+sno+"' and course.cno=sc.cno and student.sno=sc.sno";也就是说我要在查询的数据跟网页中输入的信息的“名字”要对上号
      

  4.   


    没想到“libin_ftsafe”兄这么快
    ^_^
      

  5.   

    不过你说的
    “where 
        a.sno = c.sno and b.cno = c.cno
        ...  --  网页中要输入的字段的条件”
    是不是要用and连接啊?
    能不能再具体点?
    因为我经常漏写什么的
      

  6.   

    构造动态的语句
    String sql="select a.sno,a.sname, a.ssex,a.sage,a.sdept,b.cno, 
                       b.cname,b.cpno, b.ccredit, c.grade
                  from student a,course b ,sc c
                 where a.sno = c.sno and b.cno = c.cno and
                       a.sno like '"s"' + '%' and
                       a.sname like '"snams" + '%' and
                       ....
      

  7.   

    能不能用or啊我想这sql语句能根据其中任何一个字段输入来查询或者是其中任何几个字段来查询
      

  8.   

    可不可以改为or啊?
    就象这样:
    String sql="select a.sno,a.sname, a.ssex,a.sage,a.sdept,b.cno, 
                       b.cname,b.cpno, b.ccredit, c.grade
                  from student a,course b ,sc c
                 where a.sno = c.sno and b.cno = c.cno or
                       a.sno='"+sno+"' or
                       a.sname='"+sname+"'or
                       ....
      

  9.   

    又是 and 又是 or 的行不行啊?
      

  10.   

    只能用and!至于多条件综合查询,可结合javabean实现:如:  String sql="select * from student,course,sc where course.cno=sc.cno student.sno=sc.sno";
      if(!sno.equal("")){
         sql+="student.sno = '"+sno+"'";
       }  // 如果有输入学生编号,则执行该查询条件,否则,该查询条件不运行.其他学生姓名等查询件  可以类似处理