背景:
String sql = "SELECt *n" + "FROM emp LEFT JOIN dept on emp.deptno = dept.deptnon" + "WHERe emp.empno = (SELECt empno FROM emp where ename like ?)";
在编写sql语句的时候,子查询查询出来empno>1条的时候,就会报出Subquery returns more than 1 row这个异常
解决方法:在子查询的sql语句前面加一个any就可以了
String sql = "SELECt *n" + "FROM emp LEFT JOIN dept on emp.deptno = dept.deptnon" + "WHERe emp.empno = any(SELECt empno FROM emp where ename like ?)";
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)