请求 JPQL JEE
请我需要选择除具有管理员角色的员工之外的员工列表。但是我遇到了语法问题。这是代码: 从员工 e 中选择 e,除了从员工 e 中选择 e WHERE e.role = 'admin';
Please i need to select list of employees except the employees who have the role admin. However I got a syntax issue. this is the code :SELECT e FROM Employee e EXCEPT SELECT e FROM Employee e WHERE e.role = 'admin';
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从表中选择除满足条件的记录外的所有记录的最佳方法是使用带有否定比较的
WHERE
子句(任何!=
、<>
或NOT
)。您可以在此处找到有关 SQL 的
WHERE
子句的更多信息:https:// www.w3schools.com/sql/sql_where.asp在您的具体情况下,类似这样的事情应该可以解决问题:
The best way to select all records from a table except those which satisfy a condition is using a
WHERE
clause with a negative comparison (any of!=
,<>
orNOT
).You may find more information about SQL's
WHERE
clauses there: https://www.w3schools.com/sql/sql_where.aspIn your specific case, something like this should do the trick:
您似乎没有选择任何字段。
这是使用 except 的示例
You don't appear to be selecting any fields.
Here's an example of using except