2014-12-26 26 views
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" ; 

此sql查询在sql server中工作,但在mysql中不起作用。 请帮帮我!什么是在eclipse中的错误语法mysql

回答

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" ; 
+0

我试了一下,并没有奏效。 –

+0

错误:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL语法中有错误;检查与您的MySQL服务器版本相对应的手册,以便在“where TaughtBy.ssn = Faculty.ssn”附近使用正确的语法)作为teacher,其中Student.ssn ='111221111'和'在第1行 –

+0

还有另一个空间问题,即I纠正它。我只是在空格的情况下检查它 – jfun