eclipse中的错误语法mysql是什么

时间:2014-12-26 22:38:58

标签: mysql eclipse

String queryString = "select DISTINCT students.firstName, teacher.firstName, Course.title" + 
  " from Student,Faculty,Course ,(select Student.ssn, Student.firstName, Enrollment.courseId" + 
  "from Enrollment, Student" + 
  "where Enrollment.ssn = Student.ssn )as students," + 
  "(select Faculty.ssn, Faculty.firstName, TaughtBy.courseId" + 
  "from TaughtBy, Faculty where TaughtBy.ssn = Faculty.ssn )as teacher" +
  "where Student.ssn = ?  and Faculty.ssn = ? and students.courseId = teacher.courseId" ;

这个sql查询在sql server中工作,但在mysql中不起作用。 请帮帮我!

1 个答案:

答案 0 :(得分:0)

你必须在双引号之后或之前遇到空格,尝试使用空格,例如:

String queryString = "select DISTINCT students.firstName, teacher.firstName, Course.title"+ " from Student,Faculty,Course ,(select Student.ssn, Student.firstName, Enrollment.courseId"+ " from Enrollment, Student"+" where Enrollment.ssn = Student.ssn )as students,"+" (select Faculty.ssn, Faculty.firstName, TaughtBy.courseId"+ " from TaughtBy, Faculty where TaughtBy.ssn = Faculty.ssn )as teacher"+ " where Student.ssn = ? and Faculty.ssn = ? and students.courseId = teacher.courseId" ;