我有一个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;
}
如何让查询删除所有具有相同规划器的行而不仅仅是一行? 谢谢你的任何建议。
答案 0 :(得分:1)
如果要删除多行,请将where planner = (...)
更改为where planner IN (...)
。
答案 1 :(得分:0)
我想出了我的问题所以只是发布以防任何人有同样的问题。 =只返回一行,但我想返回多行,所以我不得不将查询更改为
delete from resetpassword where planner in (select planner from g_secure where planner = ucase(?) or lcase(email) = lcase(?))
现在我返回多行而不只是一行。