//在学生已有学分的基础上添加该课程的学分
public int addMark(String student_id,String class_id) throws SQLException{
int num=0;
SQLBean db = null;
Connection conn = null;
Statement stmt = null;
try {
db = new SQLBean();
String sql="update student,course,class "+
"set student. = student. + course."+
"where student.id='"+student_id+"' "+
"and class.id='"+class_id+"' "+
"and course.id = class.course_id";
conn = db.getConnection();
stmt = conn.createStatement();
num = stmt.executeUpdate(sql);
return num;
} finally {
/* db.closeStatement(stmt);
db.closeConnection(conn); */
}
}怎样将sql语句转换成能在MySQL中的正确的语句?谢谢!
有什么关系?以什么字段参照?建议贴出三个表的表结构。
update student,course,class set student. = 55 and course. =100 where student.id=95001 and class.id=1 and course.id = 1;把它拿到MYSQL命令行下执行一下就知道了
String sql="update student,course,class "+
"set student. = student. + course."+
"where student.id='"+student_id+"' "+
"and class.id='"+class_id+"' "+
"and course.id = class.course_id";有问题,course.后面缺少东西