写了一个统计学生表人数的查询接口,浏览器运行出错
idea报错
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 student’ at line 1
错误原因翻译如下:
您的SQL语法有错误;检查与MySQL服务器版本相对应的手册,以获得在第1行的“*)from student”附近使用的正确语法
检查.xml映射文件,发现报错的查询语句写法如下:
select count (*) from student;
取掉count与(*)之间的空格
select count(*) from student;
再次运行,错误随即消失。
在写sql语句时,一定要注意不要有多余的空格。



