错误: nknown column 'xxxx' in 'where clause'
Posted 人生在与不断学习。
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误: nknown column 'xxxx' in 'where clause'相关的知识,希望对你有一定的参考价值。
nknown column \'sdsds\' in \'where clause\'
运行环境:jdk1.7.0_17+tomcat 7 + spring:3.2.0 +mybatis:3.2.7+ eclipse
错误:nknown column \'sdsds\' in \'where clause\'
错误原因:数据库查询无用,可能很多写sql语句都会遇到這个问题,从字面这意思很容易得出,意思是列名不存在的意思,在下面我的数据库根本没有這个所谓的列名,這个是因为我在查询sql语句时候用到字符以及整形等,這里改成整型就没有问题
解决办法:你查询时候在对应的字符型没有加上对应的单引号
错误代码:
1 ### SQL: SELECT student_id as studentId,student_password as studentPassword FROM xxhh_table_user WHERE student_id=15301061 AND student_password=sdsds 2 ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column \'sdsds\' in \'where clause\' 3 ; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column \'sdsds\' in \'where clause\' 4 at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231) 5 at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) 6 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71) 7 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365) 8 at com.sun.proxy.$Proxy15.selectOne(Unknown Source) 9 at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:160) 10 at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68) 11 at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) 12 at com.sun.proxy.$Proxy21.selectByPrimaryKey(Unknown Source) 13 at com.xxhh.service.impl.LoginServiceImpl.selectByPrimaryKey(LoginServiceImpl.java:77) 14 at com.xxhh.controller.LoginController.selectUserAndPassword(LoginController.java:126) 15 at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source) 16 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 17 at java.lang.reflect.Method.invoke(Method.java:601) 18 at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) 19 at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) 20 at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) 21 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776) 22 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705) 23 at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) 24 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) 25 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) 26 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) 27 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
相关代码:
以上是关于错误: nknown column 'xxxx' in 'where clause'的主要内容,如果未能解决你的问题,请参考以下文章
QTCreator 璋冭瘯锛歶nknown debugger type "No engine"
错误代码 1366 Incorrect integer value 'zhangsan' for column 'd
mysql 的 Unknown column '6' in 'order clause' 这是啥错误啊!! 高手们帮个忙啊!!!