go - go-pg 如何覆盖链接表
问题描述
具有以下规格的三个表:
type Devices struct {
ID int
Name string
}
和
type Features struct {
ID int
Name string
}
我创建了一个由以下结构指定的链接表:
type DevicesFeatures struct {
DeviceID int
Device *Devices
FeatureID int
Feature *Features
}
我想选择所有设备及其功能(如果有)。像下面这样的查询对我有用:
select A.name, C.name from devices as A left join devices_fearures as B on A.id =B.device_id left join features as C on C.id = B.feature_id
解决方案
推荐阅读
- python - 如何为带有参数的函数编写装饰器?
- sql - redshift regexp_substr 所有出现
- react-native - Socket IO + React Native + Rabbit MQ 架构组合?
- php - PHP 致命错误:未捕获的错误:调用未定义的函数 session_start()
- apache-camel - 有没有办法使用 Simple JMS2 组件发送带有来自标头的属性的消息?
- python - Asyncio 没有并行运行 Aiohttp 请求
- javascript - 在作为字符串传递的 iFrame 中调用函数
- python - 将字符串或文本文件转换为字典 python(不能解码 JSON 对象)
- python - 如何测试依赖硒的脚本?
- reactjs - vs-code中的人如何在现有终端上运行任何命令而不添加新终端我可以在这里使用什么快捷键?