英文:
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" +
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论