错误:You have an error in your SQL syntax;

  • 原创
  • |
  • 浏览:624693
  • |
  • 更新:

刚才写sql语句碰到了一个错误,现在小天就把它拿出来给大家分享一下。

错误的详细情况如下:Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 msg_message t' at line 6

工具/原料

  • 写sql语句的时候报mysql错误: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 'XX' at line 6

方法/步骤

  1. 1

    首先要了解这个错误,这个错误是本质是mysql数据库报的错,所以你java也好,php也好报错都是mysql反溃给控制台的。我的错误就发生在java控制台具体如图:

    错误:You have an error in your SQL syntax;
  2. 2

    找到错误的主体部分进行简单的翻译一下,英语渣的同学建议使用翻译软件具体如图:

    这里的错误主题应该是: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 msg_message t' at line 6

    错误:You have an error in your SQL syntax;
  3. 3

    根据上面的翻译我们大概得到结论:在sql语句的第6行有个语法错误。让我们去检查一下。

    由于本人的sql语句写在了mybaitis中所以要去xml配置文件中寻找,具体情况如图

    错误:You have an error in your SQL syntax;
  4. 3
    该信息未经许可获取自百度经验
  5. 4

    看了半天原来是多了一个逗号,好了去掉它。重启tomcat服务器。

    错误:You have an error in your SQL syntax;
    错误:You have an error in your SQL syntax;
  6. 5

    tomcat重新启动成功,访问刚才报错的页面,正常。

    错误:You have an error in your SQL syntax;
  7. 6

    如果帮到你请投跟本经验投上宝贵的一票,谢谢。您的投票是对我最大的鼓励。

    错误:You have an error in your SQL syntax;
    错误:You have an error in your SQL syntax;
    END

注意事项

  • 找语法错误的时候仔细点。
经验内容仅供参考,如果您需解决具体问题(尤其法律、医学等领域),建议您详细咨询相关领域专业人士。
作者声明:本篇经验系本人依照真实经历原创,未经许可,谢绝转载。
展开阅读全部