Using a subquery in 'FROM' in gorm

后端 未结 6 1449
梦谈多话
梦谈多话 2021-02-10 03:03

I would like to know how I can use a subquery in FROM clause using gorm. It would look like the following:

SELECT * FROM 
(
  SELECT foo.*
  FROM foo
  WHERE bar         


        
6条回答
  •  忘了有多久
    2021-02-10 03:38

    also could be used in join

    subQuery:=db.Find(&subTable).QueryExpr()
    
    db.
    Table("table").
    Select("*").
    Join("join (?) as t1 on t1.id==table.id", //<---round brackets for multiple rows
    subQuery).
    Find(&Rows)
    
    

提交回复
热议问题