嵌套且复杂的 select 语句
我在这里想做的很简单...显示调查者 ID 和他相应的名字... 通过根据用户类型进行选择,可以从用户表中轻松完成此操作。 但是我只想选择某种类型的调查员。这里的类比是调查员被分配到一个展览进行调查。一名调查员最多只能分配 3 个案件。现在,在分配调查员期间,我想编写一个 select 语句,该语句将仅检索已分配给小于或等于 2 个案件的调查员 ID。我已经包含了展览和用户表,其中显示了下面的示例数据。
现在我有一个想法,我必须首先从用户列表中按 ID 挑选出所有调查员,然后通过删除那些分配给 3 个案件的调查员并留下那些分配给 2 个案件的调查员来通过展览表过滤它们案例。然后我使用这个 ID 来选择调查员姓名。
最大的问题是我如何写声明?
What i want to do here is simple...display an ivestigators ID and him corresponding name...
That can be easily done from the users table by selecting based on the user type.
However i want to select only some type of investigators. The analogy here is investigators are assigned to an exhibit for them to investigate. One investigator can be assigned to a maximum of 3 cases only. Now during the assigning of investigators, i want to write a select statement that would retrieve only investigatorID's that have been assigned to less than or equal to 2 cases. I have included exhibit and users table that shows sample data below.
Now i sort of have an idea that i will have to first of all pick out all the investigators by their ID from the users list and then filter them through the exhibit table by dropping those assigned to 3 cases and leaving just those with two cases. then afterwards i use this IDs to select the Investigators name.
the big questions is how do i write the statement??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是您要找的吗?
Is that what you're looking for?