问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

图中的sql语句报错了单行子查询反回多个行,请问哪位大神知道哪里错了

发布网友 发布时间:2022-05-03 10:34

我来回答

3个回答

懂视网 时间:2022-05-03 14:55


at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:78)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
at com.sun.proxy.$Proxy167.selectOne(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:159)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:57)
at com.sun.proxy.$Proxy171.getAppearCase(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy172.getAppearCase(Unknown Source)
at com.ehl.citycockpit.judicialsupervision.service.impl.AdministrativeProceedingServiceImpl.appearRespondent(AdministrativeProceedingServiceImpl.java:106)
at com.ehl.citycockpit.judicialsupervision.controller.AdministrativeProceedingController.appearRespondent(AdministrativeProceedingController.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:117)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:106)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
... 72 more

解决办法:

在sql语句加一个limit 1 ,只取第一条

希望对你有帮助···········

sql查询一条数据,返回了两条数据idea报错

标签:admin   wrap   sso   har   select   druid   rand   pos   coding   

热心网友 时间:2022-05-03 12:03

这里的错误就在then和else后面的查询语句没有添加条件,会返回多条查询结果。
对于case when ... then ... else的判断查询,当不满足条件或满足条件后,所要执行的语句的查询结果必须为一条,否则select就不知道你要选择哪一个来填充当前行了,所以会报单行子查询反回多个行的错误。

热心网友 时间:2022-05-03 13:21

case when 里的几个语句都是。
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
请问昆山正仪到江苏省昆山市出口加工区新竹路99号 怎么坐班车最近? 跪求苏州神达电脑地址!!! 华为运动耳机挂脖式怎么配对 雅酷美挂脖式无线蓝牙防水耳机-运动时尚,自由畅听 已知函数f(x)=cos^2x-sin^2x+2根号3sinxcosx+1 原先微信有联系后来突然对方要求我对他进行朋友验证我没有他电话号码... 已知函数f(x)=cos^2x-sin^2x+2根号3sinxcosx 已知函数fx=cos^2*x-sin^2*x+2sinx*cosx,求fx的最小正周期,并求当... 已知函数f(x)=cos2x-sin2x 4sinx·cosx求f(x)的最小正周期,并求当x为... 已知f(x)=cos^2x-sin^x+2sinxcosx。①求函数最小正周期②当x∈【0... NBA谁穿过58号球衣? 保罗58是什么梗? 季后赛最大分差是58分吗 老鹰VS魔术直播 2011NBA季后赛老鹰对魔术直播 4.20老鹰VS魔术直播视频录像重播回放 保罗的“58”到底是什么梗? 跪求NBA季后赛黄蜂输58分的全场录像 求NBA全名星周末的各项时间 马刺vs勇士3月20日哪个台直播 09全明星赛什么时候直播? 中脉打通后还要如何修行 用九尾佛风怎样打通中脉 佛祖说过开悟要打通中脉吗 长期念佛能打通中脉吗 如何通过打坐禅定打通中脉 密宗,禅宗哪些法门(境界)可以打通中脉 什么是中脉,打通中脉的方法,藏密中脉修炼法 西安城北客运站到大雁塔坐哪路公交? 西安火车站 到 大雁塔 怎么走 生蚝属于发物的东西吗 大雁塔离西安火车站大概多远? 压缩文件太大无法传送怎么办 冻干桑叶粉如何加工 我的手机号被人恶意注册了友看名师云课堂,友看名师云课堂这个东西是什么? 我的手机号码被人注册了友看名师云课堂? 海宁名师云课堂登录操作失败怎么办? 企业纳税合格证明在税务系统如何打印 海宁名师云课堂为什么按了退出当前账号就登不回去了? 企业所得税完税证明在哪里打印 名师云课堂能看到学生分屏吗,或者分屏在干嘛吗? 企业完税凭证在哪查询? 完税记录去哪里打印 数据库表里只显示一条数据,页面却显示2条重复的,我把sql语句那栋数据库里,条件查出来得也是2条 我昨晚梦见了一个孩子的死亡伤心了 昨天晚上梦到邻居家的小女孩得病死了,我很伤心,梦中的我哭了好久,怎么会梦到这啊 icp经营许可证怎么查询 icp许可证在哪里查询? 经营性icp证可以查询吗? icp网络文化经营许可证真假如何查? 工信部icp许可证怎么查询? 如何查询一个网站有没有ICP经营许可证