嵌套 SQL 查询
我有以下表格:
俱乐部:Club_ID |标题 |创建日期 | ...
Club_Intesect:用户 ID |俱乐部_ID |访问
我正在尝试选择可变数量的俱乐部,并加入该俱乐部中具有最高访问权限的用户的 ID。此人被视为所有者。
因此,如果 Club 100 的会员 A、B、C 分别具有访问权限 3、4 和 5:我希望最终查询从俱乐部中选择:
Club.Club_ID Club.Title Club.Created_Date Club_Intersect.User_ID
100 | "Test Club" | "Creation Date" | C |
101 | "Test Club 2" | "Creation_Date" | Highest Access User |
...
I have the following tables:
Club: Club_ID | Title | Created_Date | ...
Club_Intesect: User_ID | Club_ID | Access
I'm trying to select a variable number of clubs, and join the ID of the user with the highest access in that club. This person is considered the owner.
So if Club 100 has Members A, B, C with access 3,4, and 5 respectively: I want the final query to select from club:
Club.Club_ID Club.Title Club.Created_Date Club_Intersect.User_ID
100 | "Test Club" | "Creation Date" | C |
101 | "Test Club 2" | "Creation_Date" | Highest Access User |
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
未经测试,但你明白了
Not tested but you get the idea
我认为这可以使用嵌套 SQL 查询来选择您想要的俱乐部。您没有在返回的结果中指定您想要的内容,因为此查询只会检索 Club 列。
I think that would work for selecting the club you want, using a nested SQL Query. You didn't specify what you wanted in your returned results, because this query would only retrieve the Club columns.