我有一个SQL删除查询,需要两个参数才能运行。当我运行查询时,我得到:
com.web.command.exceptions.DatabaseException: The result of a scalar fullselect, SELECT INTO statement, or VALUES INTO statement is more than one row.. SQLCODE=-811, SQLSTATE=21000, DRIVER=4.14.111
我的查询是:
delete from RESETPASSWORD where planner = (select planner from g_secure where planner = ucase(?) or lcase(email) = lcase(?))
我用来设置删除的Java是:
public boolean deleteByPlannerAndEmail(String planner, String email) throws DatabaseException{
Connection conn = null;
PreparedStatement ps = null;
try {
conn = dataAccess.grabConnection("system", "ResetPasswordDAO.deleteByPlanner(planner)");
ps = conn.prepareStatement(SQL_DELETE_BY_PLANNER);
ps.setString(1, planner);
ps.setString(2, email);
ps.executeUpdate();
} catch (Exception e) {
throw new DatabaseException(e.getMessage());
} finally {
dataAccess.release(conn, ps,null);
}
return true;
}
我如何获得查询以删除具有同一计划程序的所有行而不仅仅是一行?
感谢您的任何建议。
最佳答案
如果要删除多行,请将where planner = (...)
更改为where planner IN (...)
。