SQL 语法错误排查指南:如何解决 "You have an error in your SQL syntax" ?

sql 语法错误排查指南:如何解决

解决“you have an error in your sql syntax”错误

这个问题出现的原因在于sql语句中存在语法错误。这个问题涉及的错误是:

java.sql.sqlsyntaxerrorexception: you have an error in your sql syntax; check the manual that corresponds to your mysql server version for the right syntax to use near 'from graduate-college' at line 6

仔细检查后,发现问题出在一个多余的逗号。修改后的正确语句如下:

select date-year, college-name , graduate-number , employment-number , id
from graduate-college

此外,还可以看到有些字段的名称包含连字符(-)。在数据库设计中,建议使用帕斯卡命名法或蛇形命名法。帕斯卡命名法首字母大写,而蛇形命名法用下划线分隔单词。

select date-year, collegename , graduatenumber , employmentnumber , id
from graduatecollege

或者

select `date-year`, `college-name`, `graduate-number`, `employment-number`, `id`
from `graduate-college`

以上就是SQL 语法错误排查指南:如何解决 "You have an error in your SQL syntax" ?的详细内容,更多请关注其它相关文章!