当我从Derby数据库中选择一个条目时,我在java中有错误

时间:2017-01-15 16:56:16

标签: sql jdbc derby

这是我的SQL查询

"SELECT doctor.id,users.first_name,users.last_name,users.email,users.password, users.birthday,users.address,users.phone,users.role_id,doctor.id_type,specialty.name, count(patient.id)as count_patient"
            + "FROM  patient RIGHT JOIN users INNER JOIN doctor ON users.id=doctor.id "
            + "INNER JOIN  specialty ON specialty.id=doctor.id_type ON doctor.id =patient.id_doctor)"
            + "GROUP BY doctor.id,users.first_name,users.last_name,users.email,users.password,users.birthday,users.address,users.phone,users.role_id,doctor.id_type,specialty.name ORDER BY users.first_name";  

我的eclepse错误

[ERROR]      DoctorDAO(sortByFirstName):185 - Syntax error: Encountered "patient" at line 1, column 204.
java.sql.SQLSyntaxErrorException: Syntax error: Encountered "patient" at line 1, column 204.
    at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)....

我知道桌子已经设置好,并且' SQL'查询在IJ控制台德比中执行。

1 个答案:

答案 0 :(得分:1)

您似乎错过了声明中的空格:count_patient" + "FROM如果不这样做,我建议打印字符串并将其粘贴到您的问题中。