我正在使用jpql jpa eclipselink以下查询将不起作用:
SELECT c FROM TableA c WHERE c.forumId = :forumId AND c.isDefault = true HAVING MAX (c.validFrom)
错误消息“表达式不是有效的条件表达式”
答案 0 :(得分:2)
带有namespace Management\ForgotPassword;
use Management\IForgotPassword;
class ForgotPasswordEndUserDb implements IForgotPassword {
public function GetUserByUserName($userObject) {
}
}
表达式的use Management\IForgotPassword;
class ForgotPasswordEndUserAPIController extends Controller
{
private $ForgotPassword;
public function __construct(IForgotPassword $ForgotPassword)
{
$this->ForgotPassword = $ForgotPassword;
}
public function ForgotPassword(ForgotPasswordRequest $request)
{
$user = [
'email' => $request["email"],
'Is_Active' => 1,
];
$ForgotPasswordResponse = $this->ForgotPassword->GetUserByUserName($user);
}
}
子句only works。
HAVING子句允许对GROUP BY的结果进行过滤。
您的问题是:
我希望获得最大有效值我如何使它成为表达式
但是您可以在没有HAVING
和GROUP BY
的情况下进行查询以完成所需的操作:
GROUP BY
如果您想使用HAVING
和select c from TableA c WHERE c.validFrom = (
SELECT MAX(c2.validFrom)
FROM TableA c2
WHERE c2.Id = c.Id AND c.forumId = :forumId AND c.isDefault = true
)
,则可以执行以下操作:
GROUP BY