Hibernate和MYSQL:您的SQL语法有错误?

huangapple go评论68阅读模式
英文:

Hibernate and MYSQL: You have an error in your SQL syntax?

问题

以下是翻译好的内容:

我在我的 Java 代码中有以下查询:

String queryString = "select \r\n" +
        "cms.status_id as 'statusId',\r\n" +
        "cms.status_label as 'statusLabel',\r\n" +
        "csl.status as 'status',\r\n" +
        "from "+client+".my_status cms \r\n" +
        "join "+client+".status_list csl on csl.status = cms.status_id\r\n";

当我运行代码时,我得到以下错误:

SQL 错误:1064,SQL 状态:42000
您的 SQL 语法有误;请检查与您的 MySQL 服务器版本对应的手册以获取正确的语法。

是什么导致了这个问题?我无法看出查询中有什么问题,我手动执行时可以正常工作。

英文:

I have the following query in my java code:

String queryString = "select \r\n" +
        "cms.status_id as 'statusId',\r\n" +
        "cms.status_label as 'statusLabel',\r\n" +
        "csl.status as 'status',\r\n" +
        "from "+client+".my_status cms \r\n" +
        "join "+client+".status_list csl on csl.status = cms.status_id\r\n";

When I run the code I get the following error:

SQL Error: 1064, SQLState: 42000
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

What could be causing this? I cannot seen an issue with my query and manually I am able to get it working.

答案1

得分: 2

你在这行多了一个逗号:

 "csl.status as 'status',\r\n" +
英文:

You have an extra comma in this line:

 "csl.status as 'status',\r\n" +

huangapple
  • 本文由 发表于 2020年8月17日 22:46:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/63453247.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定