在使用 Go Gorm 库进行关联查询时,如果您需要指定关联表名,可以使用以下方法:

db.Preload("CustomOrders", "table_name = 'custom_orders'").Find(&companies)

其中,CustomOrders 是关联的结构体名称,table_name = 'custom_orders' 是指定关联的表名为 custom_orders。

通过这种方式,您可以根据实际情况灵活指定关联表名。

Go Gorm: 指定关联表名