sql - 按国家/地区分组,带有桥接表
问题描述
我不太确定使用下表编写返回具有社区的国家/地区的查询。桥接表CommunityLocation
是我可以查找公司及其位置但不太确定如何真正塑造此查询的地方。
Community
community_id
Location
location_id
country_id
Country
country_id
CommunityLocation
community_id
location_id
所以我只需要一个包含社区的国家 ID 列表。
解决方案
我认为这是你需要的:
select distinct
c.country_id
from
countires c
join Location l
on c.country_id = l.country_id
join CommunityLocation cl
on cl.location_id = l.location_id
推荐阅读
- java - 如何通过嵌套查看器中的用户 ID 检索 Firebase 实时数据库数据?
- java - __c 选项列表的 Camel SalesForce 插件问题
- swift - 带有图标的 macOS 菜单栏文本
- reactjs - 如何将 NextJS 页面下载为静态 HTML 文件?
- c# - 在 Intent Architect 模板中,我可以解析一个类型(从一个字符串),以便它包含适当的 using 语句吗?
- c# - 用户退出webapp时如何自动刷新?
- reactjs - 我的材料 ui 中的滑块不连续
- android - 在 Android 中为触摸覆盖透明
- java - 从 Kotlin 以编程方式配置 Log4J
- javascript - When a cron job is executed and there is already a cron running, are they running simultaneously?