你可以采用VO的方式来编写JAVABEAN.SQL语句:三张表各自的主键进行关联了.
解决方案 »
- (select count(*) )和(select count(*) )比较条件问题(第二个帖子)?
- oracle id自动增长,我用了序列+触发器,但是有错误。麻烦大家帮我看看!
- 删除表和索引 您的帖子 标题过短
- 关于row_number() over (partition by)的问题
- 一个新手的问题?
- 全公司都讨论了2天,不能解决,只好问大家了。
- 怎样将查询结果写入到一个文件中
- 怎么使用ORACLE开发库,而不使用ODBC来访问数据库。
- SQL 转换成oracle 写法
- oracle select语句如何进行判断。
- 帮忙写个主从表查询的SQL语句
- 想得到某个表的某个字段的最大值,写了个函数,帮忙看看错在哪里?
union
select cno,cname,cpno,ccredit from course
union
select sno,cno,grade from sc
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
... -- 网页中要输入的字段的条件
就像是String sql="select * from student,course,sc where student.sno = '"+sno+"' and course.cno=sc.cno and student.sno=sc.sno";也就是说我要在查询的数据跟网页中输入的信息的“名字”要对上号
没想到“libin_ftsafe”兄这么快
^_^
“where
a.sno = c.sno and b.cno = c.cno
... -- 网页中要输入的字段的条件”
是不是要用and连接啊?
能不能再具体点?
因为我经常漏写什么的
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
....
就象这样:
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
....
if(!sno.equal("")){
sql+="student.sno = '"+sno+"'";
} // 如果有输入学生编号,则执行该查询条件,否则,该查询条件不运行.其他学生姓名等查询件 可以类似处理