小编Raj*_*nji的帖子

使用 GORM 处理 GO lang 中 sql 的多个结果集

之前类似的问题可以追溯到2012年,但没有解决,所以我不得不重新问。

struct type DualTable{
  table1 []Table1
  table2 []Table2
  }

  struct type Table1{
  A string
  B string
  }

  struct type Table2{
  P string
  Q string
  }

  var dualtable []DualTable
  var table1 []Table1
  var table2 []Table2

  func main(){
  //trial 1 :failed as i get only table1 result
  db.Raw("select * from table1 select * from table2").Scan(&table1).Scan(&table2)

    //trial 2 :failed as i get only table2 result
  db.Raw("select * from table2 select * from table1").Scan(&table1).Scan(&table2)

  //trial 3 : failed as got nothing
  db.Raw("select * from …
Run Code Online (Sandbox Code Playgroud)

sql-server api struct go go-gorm

4
推荐指数
1
解决办法
3098
查看次数

标签 统计

api ×1

go ×1

go-gorm ×1

sql-server ×1

struct ×1